Skip to content

Clean up lock entries for rejected KV writes - #1186

Merged
tnull merged 1 commit into
lightningdevkit:mainfrom
benthecarman:validate-keys-before-locking
Oct 22, 2026
Merged

tnull merged 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.

@tnull tnull left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I guess.

@tnull
tnull merged commit 68c01a1 into lightningdevkit:main Oct 22, 2026
17 of 25 checks passed
@benthecarman
benthecarman deleted the validate-keys-before-locking branch October 22, 2026 21:01
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.

3 participants