Follow-ups to the withLock() completion purge retry

Open
#1,122 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
45/100
Issue type
Refactor
Clarity
Mostly clear
Activity status
Active
Tech stack
cpp, node.js
Domain
backend, databases

Research direction

Read src/binding/database/db_descriptor.cpp and the releaseDescriptorPin() helper introduced by #1110; compare the existing retry sites in the backup/checkpoint state destructors and purgeAfterCommit(). The issue describes three follow-ups, including an allocation failure edge case and a Deno timing concern. Done means deciding which follow-ups to address and aligning completeLockCallback with the shared helper where appropriate.

Written by the indexing model from the issue text.

Description

Context

The #1092 fix (branch fix/withlock-purge-skip) makes withLock() completions in src/binding/database/db_descriptor.cpp retry DBRegistry::PurgeIfUnreferenced() after releasing their transient descriptor pin (completeLockCallback / LockCompletionPurge). Pre-push review left three follow-ups, all small and none reopening the leak.

Follow-ups

  1. Fold into the shared helper. This is the third copy of the "release the pin, then retry the purge" tail, after the backup/checkpoint state destructors and purgeAfterCommit(). #1110 adds releaseDescriptorPin() for it. Whichever of #1110 and the #1092 fix merges second should switch completeLockCallback to it. Consider whether the helper should carry the lock completion's post-release use_count() == 1 fast path, which keeps ordinary completions off databasesMutex.
  2. Allocation failure loses the retry. descriptorKey() copies the path strings while the second, brief pin is held. If that copy throws, the pin is released with no retry. Every existing retry site has the same best-effort limit. Making the key copy non-throwing (for example, caching the key on the descriptor) would close it for all of them.
  3. Purge runs after the caller's promise settles. This matches commit completion, so a possible close-time flush never runs ahead of the caller's continuation. On Deno, which runs the continuation inside the settle call, that continuation can briefly see an unreferenced database still registered. Deno is local-only and unsupported, so this is noted rather than fixed.

Review-Deferral: 0c80b1bff4f36a9c severity=nit category=maintainability
Review-Deferral: 4511645710d48f61 severity=nit category=concurrency
Review-Deferral: 2f0dfed9b51352fa severity=minor category=reliability

🤖 Generated with Claude Code (Claude Opus 5.5); posted via @cb1kenobi.

Dominant language
C++
Stars
24
Forks
3
Avg merge
1d 14h
Merged PRs (30d)
102

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from HarperFast/rocksdb-js

All issues in HarperFast/rocksdb-js

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.