Skip to content

Commit

Permalink
fix(bigtable): Do not retry conditional mutate (#11437)
Browse files Browse the repository at this point in the history
  • Loading branch information
bhshkh authored Jan 15, 2025
1 parent b6ec918 commit ce8c9b1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 14 deletions.
5 changes: 1 addition & 4 deletions bigtable/bigtable.go
Original file line number Diff line number Diff line change
Expand Up @@ -1086,15 +1086,12 @@ func (t *Table) apply(ctx context.Context, mt *builtinMetricsTracer, row string,
}
req.FalseMutations = m.mfalse.ops
}
if mutationsAreRetryable(req.TrueMutations) && mutationsAreRetryable(req.FalseMutations) {
callOptions = retryOptions
}
var cmRes *btpb.CheckAndMutateRowResponse
err = gaxInvokeWithRecorder(ctx, mt, "CheckAndMutateRow", func(ctx context.Context, headerMD, trailerMD *metadata.MD, _ gax.CallSettings) error {
var err error
cmRes, err = t.c.client.CheckAndMutateRow(ctx, req, grpc.Header(headerMD), grpc.Trailer(trailerMD))
return err
}, callOptions...)
})
if err == nil {
after(cmRes)
}
Expand Down
13 changes: 3 additions & 10 deletions bigtable/retry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,16 +119,9 @@ func TestRetryApply(t *testing.T) {
condMut := NewCondMutation(ValueFilter(".*"), mutTrue, mutFalse)

errCount = 0
code = codes.Unavailable // Will be retried
if err := tbl.Apply(ctx, "row1", condMut); err != nil {
t.Errorf("conditionally mutating row with retries: %v", err)
}
row, err = tbl.ReadRow(ctx, "row1") // row1 already in the table
if err != nil {
t.Errorf("reading single value after conditional mutation: %v", err)
}
if row != nil {
t.Errorf("reading single value after conditional mutation: row not deleted")
code = codes.Unavailable // Won't be retried
if err := tbl.Apply(ctx, "row1", condMut); err == nil {
t.Errorf("conditionally mutating row with no retries: no error")
}

errCount = 0
Expand Down

0 comments on commit ce8c9b1

Please sign in to comment.