Repository navigation
Sub-account create race, Web Push drain on shutdown, gofmt - #75
Merged
Merged
Conversation
A create that registered or reinstated its address disables it again when no grant comes of it. It decided that from its own error, skipping the disable only on ErrAlreadyExists. But the owner's limit is checked before the insert, so the loser of a race for the same address can be told the limit is reached instead, and it then disabled the address under the winner's grant. - Before disabling, ask the store whether the address has a grant, holding the lock grant creation takes for the owner (Store.UnlessGranted). The error only decides when the store can't be asked. - A create that found its address already registered confirms it accepts once its own grant is stored, in case the create that registered it failed and undid the registration in between. - api-key create (CLI) uses the same check, and opens the database before registering the address. Fixes #72. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Shutdown cancelled the push context before waiting, so the 5 seconds it allowed only bounded how long workers took to notice. Pushes for messages committed just before or during the HTTP drain were dropped. Hub.DrainContext stops accepting jobs, lets the workers send what is queued and in flight, and cancels the remainder only when its deadline passes. Graceful shutdown uses it; the server-error path still cancels. Fixes #73. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Three follow-ups from the review of #71.
Sub-accounts: a failed create never disables an address that has a grant (fixes #72)
A create that registered or reinstated its address disables it again when no grant comes of it. It decided that from its own error and skipped the disable only on
ErrAlreadyExists. The owner's limit is checked before the insert, so the loser of a race for the same address can be told the limit is reached instead, and it then disabled the address under the winner's live grant.Store.UnlessGranted). The error type only decides when the store can't be asked.api-key createuses the same check, and opens the database before registering the address.Web Push: send what is queued on shutdown instead of cancelling it (fixes #73)
Shutdown cancelled the push context before waiting, so pushes for messages committed just before or during the HTTP drain were dropped.
Hub.DrainContextstops accepting jobs, lets the workers send what is queued and in flight, and cancels the remainder only when its 5 second deadline passes. The server-error exit path still cancels immediately.gofmt on
internal/handlers/transaction.go(one blank line).Testing
TestSubAccountCreateLoserLeavesWinnersAddressandTestSubAccountCreateConfirmsAddressItDidNotRegisterinterleave the two creates through a hook in the fake identity service. Both fail onmainand pass here.TestHubDrainContext_SendsQueuedPushesandTestHubDrainContext_CancelsWhatIsLeftAtTheDeadline.go vet ./...andgo test -race ./...pass with the PostgreSQL-backed tests enabled (161 pass, none skipped).🤖 Generated with Claude Code