Skip to content

Conversation

@iav
Copy link
Contributor

@iav iav commented Jan 16, 2026

Summary

  • Add user feedback when memoize cache lock is held by another process
  • Add configurable timeout via MEMOIZE_FLOCK_MAX_WAIT environment variable
  • Prevent builds from hanging indefinitely due to stale Docker containers

Problem

When a build is interrupted (e.g., via Ctrl+C or system crash), Docker containers may continue running and hold flock locks on memoize cache files in cache/memoize/. Subsequent builds would hang indefinitely at the "artifact [ kernel :: kernel() ]" stage without any feedback to the user.

Solution

Instead of blocking indefinitely on flock, this change:

  1. First tries non-blocking flock -n - acquires immediately if available
  2. If lock is busy, informs the user with actionable message
  3. Waits with periodic status messages (every 10s by default)
  4. Optionally times out after configurable duration
  5. Suggests checking for stale containers: docker ps -a | grep armbian

New Configuration Variables

Variable Default Description
MEMOIZE_FLOCK_WAIT_INTERVAL 10 Seconds between status messages while waiting
MEMOIZE_FLOCK_MAX_WAIT 0 Maximum wait time in seconds (0 = infinite, for backward compatibility)

Test plan

  • Build with no other processes running - should work as before
  • Start a build, interrupt it, start another - should show waiting message
  • Set MEMOIZE_FLOCK_MAX_WAIT=30 and test timeout behavior
  • Verify Ctrl+C works during lock wait

🤖 Generated with Claude Code

@iav iav requested review from a team and igorpecovnik as code owners January 16, 2026 20:18
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 16, 2026

📝 Walkthrough

Walkthrough

Modifies the memoization cache file locking mechanism in a single script to replace immediate blocking locks with non-blocking, timed locks featuring configurable retry intervals and maximum wait durations, with periodic status alerts during the waiting period.

Changes

Cohort / File(s) Summary
Memoization Locking Enhancement
lib/functions/general/memoize-cached.sh
Changed from blocking flock to non-blocking flock with retry loop and timeout logic. Added MEMOIZE_FLOCK_WAIT_INTERVAL (default 10s) and MEMOIZE_FLOCK_MAX_WAIT (default 0/infinite) configuration variables. Lock acquisition now emits progress alerts while waiting, failure alerts on timeout, and success alerts with total wait time.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 A lock that waits with patience true,
No blocking here—we'll try anew!
With timed retries and friendly cheer,
The memoize cache holds files dear.
Progress whispers as we stand,
Till the lock is in our hand! 🔓

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: adding user feedback and configurable timeout for the flock mechanism in memoization, which matches the core objective of improving lock handling behavior.
Docstring Coverage ✅ Passed Docstring coverage is 90.91% which is sufficient. The required threshold is 80.00%.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Docstrings were successfully generated.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions bot added 02 Milestone: First quarter release size/large PR with 250 lines or more Needs review Seeking for review Framework Framework components labels Jan 16, 2026
@iav iav marked this pull request as draft January 16, 2026 20:19
When the memoize cache lock is held by another process (e.g., a stale
Docker container from a previous interrupted build), the build would
hang indefinitely without any feedback to the user.

This change:
- First tries non-blocking flock, acquiring immediately if available
- If lock is busy, informs user and waits with periodic status messages
- Adds MEMOIZE_FLOCK_WAIT_INTERVAL (default 10s) for message frequency
- Adds MEMOIZE_FLOCK_MAX_WAIT (default 0=infinite) for optional timeout
- Allows user to interrupt with Ctrl+C
- Suggests checking for stale containers: docker ps -a | grep armbian

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@iav iav force-pushed the fix/memoize-flock-timeout branch from 2cd603a to a968504 Compare January 16, 2026 20:21
@github-actions github-actions bot added size/small PR with less then 50 lines and removed size/large PR with 250 lines or more labels Jan 16, 2026
@iav
Copy link
Contributor Author

iav commented Jan 16, 2026

@CodeRabbit review

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 16, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 16, 2026

Note

Docstrings generation - SUCCESS
Generated docstrings for this pull request at #9263

coderabbitai bot added a commit that referenced this pull request Jan 16, 2026
Docstrings generation was requested by @iav.

* #9262 (comment)

The following files were modified:

* `lib/functions/general/memoize-cached.sh`
@iav iav marked this pull request as ready for review January 17, 2026 03:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

02 Milestone: First quarter release Framework Framework components Needs review Seeking for review size/small PR with less then 50 lines

Development

Successfully merging this pull request may close these issues.

1 participant