Repository navigation
fix(committer)!: keep transient vault failures retryable on the config, envelope and row-read paths - #2255
Conversation
…g, envelope and row-read paths A database failure while committing a block now reaches the committer's retry as the storage error it is, instead of being read as a missing envelope, a finished result set or a discarded configuration. Config transactions: the vault marks a config transaction Busy when its read-write set is opened, and a commit that fails after that leaves it Busy. CommitConfig accepts a Busy config transaction as well as an Unknown one, so the retry or a replay after restart applies it. applyConfigCommit no longer discards the transaction on failure, because the configuration is already in force by then. ReloadConfigTransactions stops at a Busy config transaction instead of waiting for it, so a node that crashed mid-commit starts, and delivery replays the block. Envelope checks: driver.EnvelopeService.Exists returns (bool, error), and the committer, both rwset loaders and the rwset processor return the error. SimpleKeyDataStore.GetData passes read errors through the store's error wrapper, so a lost Postgres connection matches driver.ErrConnectionLost. commitUnknown returns a transient error from filterUnknownEnvelope instead of skipping the transaction; other filter errors still skip it. fabric.EnvelopeService.Exists keeps its bool result and returns false when the store cannot be read. Row reads: the SQL iterator returns rows.Err() when reading rows fails, so a truncated result is no longer taken for a complete one. Vault.Statuses reads through iterators.ForEach so that error is not dropped. The error is not yet mapped to driver.ErrConnectionLost (hyperledger-labs#2251). BREAKING CHANGE: driver.EnvelopeService.Exists returns (bool, error). Implementations of the interface must return the store's error. Fixes hyperledger-labs#2248 Signed-off-by: Marcus Brandenburger <bur@zurich.ibm.com>
|
Hey @mbrandenburger 👋 thanks for the PR! This comment updates automatically as you push changes -- think of it as your PR's live scoreboard! PR Checks✅ DCO Sign-off -- All commits have valid sign-offs. Nice work! ❌ GPG Signature -- Heads up! The following commits don't have a verified GPG signature:
You'll need to sign your commits with GPG (e.g. ✅ Merge Conflicts -- No merge conflicts detected. Smooth sailing! ✅ Issue Link -- Linked to #2248 (assigned to you). ⏳ All checks must pass before this PR can be reviewed. You've got this! |
There was a problem hiding this comment.
Review: does this address #2248?
Checked out at 3207549db.
go test -race -count=1 ./platform/fabric/... committer, transaction, rwset, sql/common, vault -> all ok
CI: all green; bot: DCO pass, GPG FAIL (3207549db)
What it fixes
| Claim | Verified how |
|---|---|
| Config commit failure no longer discards; retry succeeds | TestCommitConfigRetriesATransientVaultFailure passes; read applyConfigCommit/CommitConfig |
| Envelope existence error is retryable | read all Exists callers (committer, rwset loaders, fabricx); TestCommitUnknownReturnsTransientFilterError |
rowIterator.Next surfaces rows.Err() |
sqlmock test; grep found no other raw Next loops dropping errors |
Non-blocking
- #2248 asked for an error-returning variant rather than changing the exported
Existssignature; the PR changesdriver.EnvelopeService.Exists(breaking for external implementers). Please justify or add the variant. - #2248 said to discard only on a deterministic failure;
applyConfigCommitnow never discards, so a non-transientCommitTXfailure leaves the config tx Busy and is retried forever on replay. Considerclassify(err). ReloadConfigTransactionsnow stops at a Busy config tx instead of sleeping and retrying; please confirm no later sequence can exist behind it.
Recommendation
Good fix overall; address the two deviations.
|
This pull request does not currently match the merge queue conditions, so it cannot be queued from here. The box comes back if it matches again. |
|
👋 Hi @mbrandenburger! Great work on your recent contribution! 🎉 Here are some issues you might want to explore next: Happy coding! 🚀 |
Summary
A database failure while committing a block now reaches the committer's retry as
ErrConnectionLost(or another errorclassifyretries), instead of being read as a missing envelope, a finished result set or a discarded configuration.Fixes #2248
Differences from the issue
A failed config commit leaves the config transaction Busy, not Invalid.
NewRWSetwrites Busy to the status table. WhenCommitTXfails, the vault has already unmapped the read-write set, so the follow-upDiscardTxfails too and only logs. The retry then fails inCommitConfigwithinvalid configtx's [configtx_1] status [3](3 is Busy). DroppingDiscardTxalone does not fix that. On restart,ReloadConfigTransactionswaited on a Busy config transaction forever, so the node hung at startup.applyConfigCommitnever discards, not even on a deterministic failure. The issue suggests discarding when the failure is deterministic. That would mark the config transaction Invalid, and bothCommitConfigandReloadConfigTransactionsreject an Invalid config transaction, so the node could neither commit the block nor start until someone edited the vault by hand. Leaving it Busy avoids that:retryBlockreturns it at once and delivery stops with the error logged and counted. It is not retried in a loop.applyConfigCommitruns, so Invalid would also be wrong.driver.EnvelopeService.Existschanges signature instead of gaining a variant. Adding a method to the interface breaks implementers just as much as changing the signature, since every implementation must provide it. A variant would also leave the rwset loaders and the processor swallowing the error, and they reach the same commit path throughextractStoredEnvelopeToVault. The exportedfabric.EnvelopeService.Existskeeps itsboolsignature (see Breaking change).ReloadConfigTransactionsstops at a Busy config transaction. On a single node, no later sequence can be committed behind a Busy one. Config transactions commit one per block, in block order. A degraded block stops delivery, and a transient failure retries the same block. So every sequence after a Busyconfigtx_Nis Unknown, and the replay that applies N goes on to N+1. Several replicas sharing one vault are not covered: a replica can see another replica's in-flightconfigtx_Nas Busy and stop there. That is #2253, which should be resolved before the next release.Changes
committer/config.go,committer/committer.go):applyConfigCommitno longer discards on failure. The configuration is already in force at that point.CommitConfigaccepts a Busy config transaction as well as an Unknown one.ReloadConfigTransactionsstops at a Busy config transaction. Delivery resumes from the last non-Busy transaction, so the config block is replayed.driver.EnvelopeService.Existsreturns(bool, error).fabric.EnvelopeService.Existskeeps itsboolresult and returns false when the store cannot be read.SimpleKeyDataStore.GetDatapasses read errors through the store's error wrapper. Without this, a lost Postgres connection never matchesErrConnectionLost, and the envelope change would not retry on a real database.commitUnknownreturns a retryable error fromfilterUnknownEnvelopeinstead of skipping the transaction.filterUnknownEnvelopereturns itsStatuserror. Other filter errors still skip, as before.rowIterator.Nextreturnsrows.Err()oncerows.Next()is false.Vault.Statusesused a loop that would drop that trailing error and now usesiterators.ForEach.Breaking change
driver.EnvelopeService.Exists(ctx, txid) boolbecomes(bool, error). Implementations must return the store's error instead of false. The exported wrapperfabric.EnvelopeService.Existsis unchanged. Panurus neither implements nor callsdriver.EnvelopeService, so it needs no change. Panurus usesNewIteratorin about 15 places, and all of them handle the new trailing error.Tests
Each test below fails on
mainand passes with this change:TestCommitConfigRetriesATransientVaultFailure: a real memory vault whoseStorefails once withErrConnectionLost. The error classifies as retry, the config transaction stays Busy, and the secondCommitConfigmakes it Valid.TestReloadConfigTransactionsAdditionalBranches/stops_at_a_busy_config_tx: hangs onmain, returns with the fix.TestCommitUnknownReturnsEnvelopeLookupError: the realenvsover a store whoseExistsEnvelopefails. The error reachesCommitTXas retryable, and the ledger is not consulted.TestCommitUnknownReturnsTransientFilterError: a transientStatuserror while filtering is returned and classifies as retry.TestEnvelope_ExistData_WrapsError:ExistsEnvelopeerrors pass through the error wrapper.TestIteratorReturnsRowError: sqlmockRowErroris returned byNext.make checks,make unit-tests-rootandmake unit-tests-postgrespass.Follow-ups
NewIterator(used by Panurus) keeps its signature. bug(committer): keep retrying a block while Postgres is unreachable instead of stopping delivery after the retry budget #2250 is blocked on it.DiscardEndorserTransactionstill logs a failedDiscardTxand returns nil.CommitConfigremoves the reload wait, which covered a replica restarting while another replica sharing the vault commits a config transaction. Check that before the next release.Related