Retry with sentinel instead of error#531
Closed
kriszyp wants to merge 2 commits into
Closed
Conversation
…TRY_NOW When coordinatedRetry: true is set on TransactionOptions, an IsBusy conflict at commit time resolves the commit promise with RETRY_NOW_VALUE (a new exported constant) instead of rejecting with ERR_BUSY. The transaction() retry loop detects this sentinel and retries immediately without backoff, while the existing retryOnBusy/ERR_BUSY path is unchanged for callers that don't opt in. Changes: - C++: parse coordinatedRetry option in Transaction::New, store on handle; Commit async complete resolves with RETRY_NOW_VALUE on IsBusy when set - C++: define RETRY_NOW_VALUE (0x04000000) in database.h, export from binding - TS: add coordinatedRetry to TransactionOptions; update NativeTransaction.commit type; add RETRY_NOW_VALUE to constants shape - TS: Transaction.commit() returns Promise<RETRY_NOW | void>; export RETRY_NOW - TS: database.ts transaction() loop handles RETRY_NOW with immediate retry - Tests: new coordinated-retry.test.ts covering sentinel value, no-conflict path, write-write conflict retry, and raw Transaction.commit() usage - README: document coordinatedRetry option, RETRY_NOW sentinel, and usage examples Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Contributor
📊 Benchmark Resultsget-sync.bench.tsgetSync() > random keys - small key size (100 records)
getSync() > sequential keys - small key size (100 records)
ranges.bench.tsgetRange() > small range (100 records, 50 range)
realistic-load.bench.tsRealistic write load with workers > write variable records with transaction log
transaction-log.bench.tsTransaction log > read 100 iterators while write log with 100 byte records
Transaction log > read one entry from random position from log with 1000 100 byte records
worker-put-sync.bench.tsputSync() > random keys - small key size (100 records, 10 workers)
worker-transaction-log.bench.tsTransaction log with workers > write log with 100 byte records
Results from commit 6255d4d |
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.
This is the only way I have figured out how to address HarperFast/harper#415
And I've spent a lot of cycles (mine and Claude's) trying to figure out how ERR_BUSY errors are escaping our catch handlers to no avail. I think this is cleaner, more straightforward and... it works.
This specifically anticipates #526, which certainly will take more review/testing, and pulls out the retry change, but should be API compatible with this future change.
When coordinatedRetry: true is set on TransactionOptions, an IsBusy
conflict at commit time resolves the commit promise with RETRY_NOW_VALUE
(a new exported constant) instead of rejecting with ERR_BUSY. The
transaction() retry loop detects this sentinel and retries immediately
without backoff, while the existing retryOnBusy/ERR_BUSY path is
unchanged for callers that don't opt in.
Changes:
Commit async complete resolves with RETRY_NOW_VALUE on IsBusy when set
type; add RETRY_NOW_VALUE to constants shape
path, write-write conflict retry, and raw Transaction.commit() usage