Skip to content

fix: handle cache lock conflicts and clean up orphaned native state#18

Merged
monkey666-cr merged 2 commits into
monkey666-cr:mainfrom
runchen0919:fix/cache-lock-and-orphan-cleanup
May 15, 2026
Merged

fix: handle cache lock conflicts and clean up orphaned native state#18
monkey666-cr merged 2 commits into
monkey666-cr:mainfrom
runchen0919:fix/cache-lock-and-orphan-cleanup

Conversation

@runchen0919
Copy link
Copy Markdown
Contributor

@runchen0919 runchen0919 commented May 15, 2026

Summary

  • Add a three-stage retry strategy for redb database lock conflicts (try → retry after 500ms → delete & recreate) to prevent initialization failures when a previous process didn't release the lock
  • Detect and shut down orphaned native handles during nativeInitialize when the same cache_dir is reused (e.g., ClassLoader replacement that skipped nativeShutdown)
  • Call BazelBridge.shutdown() on bundle stop instead of keeping the bridge alive, relying on disk cache for classpath recovery on next restart

Test plan

  • Verify normal cache open path still works (no lock conflict)
  • Simulate lock conflict by opening the redb file from another process, confirm retry and recreation works
  • Confirm orphaned state is cleaned up when reinitializing with the same cache_dir
  • Verify bundle stop properly shuts down the native bridge
  • Run cargo test --workspace and mvn test

🤖 Generated with Claude Code

runchen0919 and others added 2 commits May 15, 2026 17:25
Add a three-stage retry strategy for redb database lock conflicts
(try → retry after 500ms → delete & recreate) to prevent initialization
failures when a previous process didn't release the lock.

Detect and shut down orphaned native handles during nativeInitialize
when the same cache_dir is reused (e.g., ClassLoader replacement that
skipped nativeShutdown). Also call BazelBridge.shutdown() on bundle
stop instead of keeping the bridge alive.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@monkey666-cr monkey666-cr merged commit b1aa263 into monkey666-cr:main May 15, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants