Skip to content

Let the re-key wait on a busy issue store as long as issue.mjs - #2

Merged
Portll merged 2 commits into
mainfrom
fix/rekey-lock-wait
Oct 11, 2026
Merged

Portll merged 2 commits into
mainfrom
fix/rekey-lock-wait

Conversation

@Portll

@Portll Portll commented Oct 11, 2026

Copy link
Copy Markdown
Owner

Fixes the Ubuntu Node 22 failure that showed up once on #1's CI run (38061636846) and passed on rerun: bin/test/issue-store-concurrency.test.mjs, "a re-key running beside live mints loses none of them".

Cause

bin/issue-rekey.mjs --write took the issue-store lock with withIssuesLock's default of 50 attempts of 20 ms each, about 1 s. That default is the request-handler budget. The lock's contract in monitor/issue-store.mjs says a CLI may wait longer, and bin/issue.mjs waits 250 attempts. On a loaded runner, the test's eight concurrent mints held the lock in turn for more than a second. The re-key then gave up with exit 4 ("issue store is locked by another process; try again"), and the test requires it to complete.

Fix

The re-key now takes the lock with attempts: 250, the same as bin/issue.mjs.

Test

The new test, "a re-key waits out a writer that holds the lock longer than a request handler would", runs in about 2 s. A child process takes the lock and holds it for 2 s, which is longer than the old budget and well inside the new one. Then the re-key runs.

  • On the unfixed re-key it fails with the same "locked by another process" error CI showed.
  • With the fix it passes. issue-store-concurrency.test.mjs passed 4/4 on three consecutive runs.
  • issue-rekey-depsretire, issue, one-mutex, focus-rekey and tracked-imports pass, and node bin/reference.mjs --check exits 0.

The re-key is a CLI, but it took the issue lock with the request
handler's budget of 50 rounds of 20ms. bin/issue.mjs waits 250. On a
loaded runner, eight mints holding the lock in turn outlasted that
second, and the re-key refused with exit 4. That failed "a re-key
running beside live mints loses none of them" once on Ubuntu Node 22. It
now waits 250 rounds. A new test holds the lock for 2s from another
process: the old re-key refuses and the new one completes.
The re-key wait test spawned its lock holder with an inline module that
imported './monitor/issue-store.mjs'. Resolved from bin/test that file
does not exist, and tracked-imports failed on every CI job: the guard
reported an untracked import, and V8 disagreed with the extractor. The
child now imports the module by a file URL built at run time, as
ledger-rotate-concurrent does.
@Portll
Portll merged commit c651bd3 into main Oct 11, 2026
35 of 36 checks passed
@Portll
Portll deleted the fix/rekey-lock-wait branch October 11, 2026 01:56
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.

1 participant