Skip to content

Clean up lock entries for rejected KV writes - #1186

Open
benthecarman wants to merge 1 commit into
lightningdevkit:mainfrom
benthecarman:validate-keys-before-locking
Open

benthecarman wants to merge 1 commit into
lightningdevkit:mainfrom
benthecarman:validate-keys-before-locking

Conversation

@benthecarman

@benthecarman benthecarman commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

SQLite and Postgres stores add a per-key lock entry before validating the key, but only remove it after a completed write. Writes or removes that fail validation leave the entry behind.

Remove the entry when validation fails.

This could never be hit in practice because we validate beforehand, but better to add in case our API changes.

Found by Project Loupe.

SqliteStore and PostgresStore register a per-key lock entry before
validating the namespace and key, but only remove it after a completed
write. Writes and removes rejected by validation therefore left their
entry behind, slowly growing the lock map for each distinct invalid
key in release builds.

Clean up the lock entry when validation fails.

This was found by Project Loupe.

This change was made with the help of Claude Code.
@ldk-reviews-bot

ldk-reviews-bot commented Oct 20, 2026 •

Copy link
Copy Markdown

I've assigned @tnull as a reviewer!
I'll wait for their review and will help manage the review process.
Once they submit their review, I'll check if a second reviewer would be helpful.

@ldk-reviews-bot
ldk-reviews-bot requested a review from tnull October 20, 2026 19:45
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