Repository navigation
Conversation
- TransactionSet/TransactionRollback now share a replaceThenMerge orchestration that fetches Running once, up front, and captures it as the transaction's oldRunning snapshot before either the replace or merge phase runs. - replaceIntent takes that snapshot as a parameter instead of fetching Running itself, closing the TOCTOU gap between two separate fetches. - lowlevelTransactionSet's late (and, for replace transactions, post-replace) oldRunning re-derivation is removed. - GetRollbackTransaction() sets the rollback's .replace from oldRunning when the original transaction had .replace set, so a replace transaction's timeout/cancel actually reverts the device instead of being a silent no-op. oldIntents replay is unchanged. - DatastoreRollbackAdapter.TransactionRollback now goes through replaceThenMerge instead of calling lowlevelTransactionSet directly, so a rollback transaction's own .replace is honored. - TransactionSet reordered so intents/replace are attached and IsNoOp() is evaluated before any replace/merge work runs. - Guard the new up-front Running fetch against a not-yet-persisted Running intent (e.g. the very first transaction on a fresh datastore), disambiguating via IntentExists instead of treating every fetch error as fatal. Tests: TransactionSet/GetRollbackTransaction coverage for replace rollback restoring pre-replace device state, plain intents-only rollback remaining oldIntents-only, and rollback transactions not starting their own rollback timer.
…pshotUpdates Addresses code-review feedback: both replaceIntent and runningSnapshotUpdates built their own TreeRoot + ImportConfig(ProtoTreeImporter(runningProto)) from scratch; factor that into one shared helper.
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! 🚀 New features to boost your workflow:
|
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
Make a replace transaction's timeout/cancel actually revert the device, instead of being a silent no-op.
The bug: a replace transaction's pre-replace Running snapshot was captured too late (after
replaceIntenthad already written back), via a separate re-derivation that was never even wired into rollback.GetRollbackTransaction()only ever replayedoldIntents, which is empty for a replace-only call — so canceling/timing out a replace did nothing.Changes
Datastore.replaceThenMerge: new shared "replace-then-merge" orchestration. Fetches Running once, up front, before either the replace or merge phase runs; captures it as the transaction'soldRunningsnapshot; then conditionally runsreplaceIntent(now taking that snapshot as a parameter instead of fetching it itself) followed bylowlevelTransactionSet.lowlevelTransactionSet's late, post-replaceoldRunningre-derivation (viaops.LeafsOfOwner) removed.Transaction.GetRollbackTransaction()now sets the rollback's.replacefromoldRunning, but only when the original transaction had.replaceset.oldIntentsreplay is unchanged.DatastoreRollbackAdapter.TransactionRollbacknow goes throughreplaceThenMergeinstead of callinglowlevelTransactionSetdirectly, so a rollback transaction's own.replaceis honored instead of silently dropped.TransactionSetreordered so intents/replace are attached to the transaction andIsNoOp()is evaluated before any replace/merge work runs (prerequisite for ticket08's Synced gate, not itself a gate).IntentExists, to avoid regressing plain intent-only transactions that previously never touched the cache for this purpose.pkg/datastore/CONTEXT.mdupdated with Replace transaction /oldRunningentries.Out of scope
Per the ticket, no Synced gate /
ErrNotSynced/RunningStore.MarkSynced(see ticket08-synced-gate.md, a separate PR).Tests
oldIntents-only (unaffected).Transaction.GetRollbackTransaction()unit tests for the conditional.replacewiring.go build ./...,go vet ./...,go test ./...all pass.Reviewed with the repo's
code-reviewskill (Standards + Spec sub-agents); one minor duplicated-code smell was found and fixed (extractednewRunningSnapshotTreeRoot).