Skip to content

fix(#632): two-phase upgrade - separate LLM enrichment from DB writes#645

Closed
jlin53882 wants to merge 1 commit intoCortexReach:masterfrom
jlin53882:fix/issue-632-v2
Closed

fix(#632): two-phase upgrade - separate LLM enrichment from DB writes#645
jlin53882 wants to merge 1 commit intoCortexReach:masterfrom
jlin53882:fix/issue-632-v2

Conversation

@jlin53882
Copy link
Copy Markdown
Contributor

@jlin53882 jlin53882 commented Apr 17, 2026

Summary

Fixes lock contention between upgrade CLI and plugin by implementing two-phase approach:

  • Phase 1: LLM enrichment (parallel, no lock)
  • Phase 2: Single lock per batch for DB writes

Reduces lock contention from N locks (one per entry) to 1 lock per batch.

Changes

  • Extract prepareEntry() for LLM enrichment (no lock)
  • Extract applyEnrichedEntry() for DB writes (within single lock)
  • Add fallback for test environment (runWithFileLock is optional)

Testing

  • Unit test: test/memory-upgrader-diagnostics.test.mjs passes

Closes #632


Issue: #632

…m DB writes

- Extract prepareEntry() for LLM enrichment (no lock)
- Extract applyEnrichedEntry() for DB writes (within single lock)
- Phase 1: Promise.all for parallel LLM enrichment
- Phase 2: Single runWithFileLock for all DB writes
- Reduces lock contention from N to 1 per batch
@chatgpt-codex-connector
Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@jlin53882
Copy link
Copy Markdown
Contributor Author

#632 開,關閉此PR

@jlin53882 jlin53882 closed this Apr 17, 2026
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.

[BUG] Lock contention between upgrade CLI and plugin causes writes to fail

1 participant