Skip to content

Commit a43fde0

Browse files
committed
kvcoord: assert on unexpected resume spans in write buffer
We could handle the resume span here, but it is very hard to test that handling since we have another layer of assertions earlier in the code. Instead, we add an additional assertion rather than handling an event we don't expect to happen. Epic: none Release note: None
1 parent 92b4af4 commit a43fde0

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

pkg/kv/kvclient/kvcoord/txn_interceptor_write_buffer.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1377,6 +1377,11 @@ func (rr requestRecord) toResp(
13771377
var ru kvpb.ResponseUnion
13781378
switch req := rr.origRequest.(type) {
13791379
case *kvpb.ConditionalPutRequest:
1380+
if !rr.stripped && br.GetInner().Header().ResumeSpan != nil {
1381+
return kvpb.ResponseUnion{},
1382+
kvpb.NewError(errors.AssertionFailedf("unexpected non-nil ResumeSpan for ConditionalPutRequest"))
1383+
}
1384+
13801385
// Evaluate the condition.
13811386
evalFn := mvcceval.MaybeConditionFailedError
13821387
if twb.testingOverrideCPutEvalFn != nil {
@@ -1390,11 +1395,6 @@ func (rr requestRecord) toResp(
13901395
// We only use the response from KV if there wasn't already a
13911396
// buffered value for this key that our transaction wrote
13921397
// previously.
1393-
// TODO(yuzefovich): for completeness, we should check whether
1394-
// ResumeSpan is non-nil, in which case the response from KV is
1395-
// incomplete. This can happen when MaxSpanRequestKeys and/or
1396-
// TargetBytes limits are set on the batch, and SQL currently
1397-
// doesn't do that for batches with CPuts.
13981398
val = br.GetInner().(*kvpb.GetResponse).Value
13991399
}
14001400

@@ -1425,12 +1425,12 @@ func (rr requestRecord) toResp(
14251425
twb.addToBuffer(req.Key, req.Value, req.Sequence, req.KVNemesisSeq, dla)
14261426

14271427
case *kvpb.PutRequest:
1428+
if !rr.stripped && br.GetInner().Header().ResumeSpan != nil {
1429+
return kvpb.ResponseUnion{},
1430+
kvpb.NewError(errors.AssertionFailedf("unexpected non-nil ResumeSpan for PutRequest"))
1431+
}
1432+
14281433
var dla *bufferedDurableLockAcquisition
1429-
// TODO(yuzefovich): for completeness, we should check whether
1430-
// ResumeSpan is non-nil if we transformed the request, in which case
1431-
// the response from KV is incomplete. This can happen when
1432-
// MaxSpanRequestKeys and/or TargetBytes limits are set on the batch,
1433-
// and SQL currently doesn't do that for batches with Puts.
14341434
if rr.transformed && exclusionTimestampRequired {
14351435
dla = &bufferedDurableLockAcquisition{
14361436
str: lock.Exclusive,

0 commit comments

Comments
 (0)