Skip to content

Commit

Permalink
Merge #35723
Browse files Browse the repository at this point in the history
35723: intentresolver: properly update intent meta and status after PENDING push r=nvanbenschoten a=nvanbenschoten

This change fixes a bug that was revealed by #35165. After performing
a push on PENDING transactions, `IntentResolver.CleanupTxnIntentsOnGCAsync`
would attempt to update its slice of intents to reflect the new transaction
metadata and status. This update was performed on a copy of the intents,
so it wasn't reflected in the intent slice passed to `cleanupFinishedTxnIntents`.

I believe that the effect of this is that cleaning up a PENDING transaction
would take an extra GC round.

The change to `TestGCQueueTransactionTable` makes the test fail without
the fix.

Release note: None

Co-authored-by: Nathan VanBenschoten <[email protected]>
  • Loading branch information
craig[bot] and nvanbenschoten committed Mar 14, 2019
2 parents 96e6557 + 3c4832b commit 1f179aa
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
21 changes: 12 additions & 9 deletions pkg/storage/gc_queue_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -683,16 +683,19 @@ func TestGCQueueTransactionTable(t *testing.T) {
func(filterArgs storagebase.FilterArgs) *roachpb.Error {
if resArgs, ok := filterArgs.Req.(*roachpb.ResolveIntentRequest); ok {
id := string(resArgs.IntentTxn.Key)
var spans []roachpb.Span
val, ok := resolved.Load(id)
if ok {
spans = val.([]roachpb.Span)
// Only count finalizing intent resolution attempts in `resolved`.
if resArgs.Status != roachpb.PENDING {
var spans []roachpb.Span
val, ok := resolved.Load(id)
if ok {
spans = val.([]roachpb.Span)
}
spans = append(spans, roachpb.Span{
Key: resArgs.Key,
EndKey: resArgs.EndKey,
})
resolved.Store(id, spans)
}
spans = append(spans, roachpb.Span{
Key: resArgs.Key,
EndKey: resArgs.EndKey,
})
resolved.Store(id, spans)
// We've special cased one test case. Note that the intent is still
// counted in `resolved`.
if testCases[id].failResolve {
Expand Down
6 changes: 3 additions & 3 deletions pkg/storage/intentresolver/intent_resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -708,9 +708,9 @@ func (ir *IntentResolver) CleanupTxnIntentsOnGCAsync(
}
// Get the pushed txn and update the intents slice.
txn = &b.RawResponse().Responses[0].GetInner().(*roachpb.PushTxnResponse).PusheeTxn
for _, intent := range intents {
intent.Txn = txn.TxnMeta
intent.Status = txn.Status
for i := range intents {
intents[i].Txn = txn.TxnMeta
intents[i].Status = txn.Status
}
}
var onCleanupComplete func(error)
Expand Down

0 comments on commit 1f179aa

Please sign in to comment.