fix(recovery): make audit recovery global and token requests idempotent#1528
Open
Aman-Cool wants to merge 1 commit intohyperledger-labs:mainfrom
Open
fix(recovery): make audit recovery global and token requests idempotent#1528Aman-Cool wants to merge 1 commit intohyperledger-labs:mainfrom
Aman-Cool wants to merge 1 commit intohyperledger-labs:mainfrom
Conversation
- Add crash-recovery to auditor RestoreTMS: if tokens were already committed to tokenDB but auditDB status is still Pending (node crashed between Append and SetStatus), heal the record directly on restart instead of waiting for a finality event that may not be re-delivered - Make AddTokenRequest idempotent with ON CONFLICT DO NOTHING so view retries after a transient failure no longer hit a UNIQUE VIOLATION on tx_id; makes the token-request write safe to replay at any point Signed-off-by: Aman-Cool <aman017102007@gmail.com>
Contributor
Author
|
@adecaro, Opened this as a follow-up to the review feedback on #1522. Kept the audit recovery logic in its own function so it's not locked to the bootstrap path; easier to call from other places if needed down the line. Let me know what you think. |
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.
Following up on the review feedback from #1522, here's the more global approach.
Audit crash recovery
Same split-brain scenario as the ttx side (PR #1507): node crashes after
auditDB.Appendwrites the token record but beforeSetStatus(Confirmed)runs. On restart,RestoreTMSre-registers a finality listener for the stuckPendingrecord; but if the finality event was already delivered before the crash, it won't come again and the record staysPendingforever.The fix: before adding the listener, check whether the tokens are already in
tokenDB. If they are, setConfirmeddirectly and move on. Extracted into a standalonerecoverAuditCommittedPendingfunction so it's easy to call from other recovery paths as the codebase evolves.Idempotent token request writes
AddTokenRequestwas doing a plainINSERTwith aPRIMARY KEYontx_id. Any view retry after a transient failure would hit aUNIQUE VIOLATIONand fail permanently instead of recovering. AddedON CONFLICT DO NOTHINGso replaying the write is safe; the record is already there, nothing to do.Together these close the two gaps pointed out in the review. Happy to adjust either if the direction isn't quite right.