@@ -1011,21 +1011,52 @@ func TestTxnReadWithinUncertaintyIntervalAfterRangeMerge(t *testing.T) {
1011
1011
// writing.
1012
1012
manuals [2 ].Increment (2000 )
1013
1013
1014
+ defer func () {
1015
+ if ! t .Failed () {
1016
+ return
1017
+ }
1018
+ t .Logf ("maxNanos=%d" , maxNanos )
1019
+ t .Logf ("manuals[2]=%d" , manuals [2 ].UnixNano ())
1020
+ }()
1021
+
1014
1022
// Write the data from a different transaction to establish the time for the
1015
1023
// key as 10 ns in the future.
1016
- _ , pErr := kv .SendWrapped (ctx , tc .Servers [2 ].DistSenderI ().(kv.Sender ), putArgs (keyC , []byte ("value" )))
1017
- require .Nil (t , pErr )
1024
+ {
1025
+ ctx , fagrs := tracing .ContextWithRecordingSpan (ctx , tc .Servers [0 ].Tracer (), "keyC-write" )
1026
+ resp , pErr := kv .SendWrapped (ctx , tc .Servers [2 ].DistSenderI ().(kv.Sender ), putArgs (keyC , []byte ("value" )))
1027
+ rec := fagrs ()
1028
+ require .Nil (t , pErr , "%v" , rec )
1029
+ defer func () {
1030
+ if ! t .Failed () {
1031
+ return
1032
+ }
1033
+ t .Logf ("keyC-write: %+v" , resp )
1034
+ t .Logf ("keyC-write: %s" , rec )
1035
+ }()
1036
+ }
1018
1037
1019
1038
// Create two identical transactions. The first one will perform a read to a
1020
1039
// store before the merge, the second will only read after the merge.
1021
1040
txn := roachpb .MakeTransaction ("txn1" , keyA , isolation .Serializable , 1 , now , maxOffset , instanceId , 0 , false /* omitInRangefeeds */ )
1022
1041
txn2 := roachpb .MakeTransaction ("txn2" , keyA , isolation .Serializable , 1 , now , maxOffset , instanceId , 0 , false /* omitInRangefeeds */ )
1023
1042
1024
- // Simulate a read which will cause the observed time to be set to now
1025
- resp , pErr := kv .SendWrappedWith (ctx , tc .Servers [1 ].DistSenderI ().(kv.Sender ), kvpb.Header {Txn : & txn }, getArgs (keyA ))
1026
- require .Nil (t , pErr )
1027
- // The client needs to update its transaction to the returned transaction which has observed timestamps in it
1028
- txn = * resp .Header ().Txn
1043
+ // Simulate a read which will cause the observed time to be set to now.
1044
+ {
1045
+ ctx , fagrs := tracing .ContextWithRecordingSpan (ctx , tc .Servers [0 ].Tracer (), "txn1-keyA-get" )
1046
+ resp , pErr := kv .SendWrappedWith (ctx , tc .Servers [1 ].DistSenderI ().(kv.Sender ), kvpb.Header {Txn : & txn }, getArgs (keyA ))
1047
+ rec := fagrs ()
1048
+ require .Nil (t , pErr , "%v" , rec )
1049
+ // The client needs to update its transaction to the returned transaction which has observed timestamps in it
1050
+ txn = * resp .Header ().Txn
1051
+ defer func () {
1052
+ if ! t .Failed () {
1053
+ return
1054
+ }
1055
+ t .Logf ("txn1-keyA-get: %+v" , resp )
1056
+ t .Logf ("txn1-keyA-get: %s" , rec )
1057
+ t .Logf ("txn1-keyA-get resp txn: %s" , txn )
1058
+ }()
1059
+ }
1029
1060
1030
1061
// Now move the ranges, being careful not to move either leaseholder
1031
1062
// C: 3 (RHS - replica) => 0 (LHS leaseholder)
@@ -1048,8 +1079,13 @@ func TestTxnReadWithinUncertaintyIntervalAfterRangeMerge(t *testing.T) {
1048
1079
1049
1080
// Try and read the transaction from the context of a new transaction. This
1050
1081
// will fail as expected as the observed timestamp will not be set.
1051
- _ , pErr = kv .SendWrappedWith (ctx , tc .Servers [0 ].DistSenderI ().(kv.Sender ), kvpb.Header {Txn : & txn2 }, getArgs (keyC ))
1052
- require .IsType (t , & kvpb.ReadWithinUncertaintyIntervalError {}, pErr .GetDetail ())
1082
+ {
1083
+ ctx , fagrs := tracing .ContextWithRecordingSpan (ctx , tc .Servers [0 ].Tracer (), "txn2get-should-rwue" )
1084
+ _ , pErr := kv .SendWrappedWith (ctx , tc .Servers [0 ].DistSenderI ().(kv.Sender ), kvpb.Header {Txn : & txn2 },
1085
+ getArgs (keyC ))
1086
+ rec := fagrs ()
1087
+ require .IsType (t , & kvpb.ReadWithinUncertaintyIntervalError {}, pErr .GetDetail (), "%s" , rec )
1088
+ }
1053
1089
1054
1090
// Try and read the key from the existing transaction. This should fail the
1055
1091
// same way.
@@ -1058,8 +1094,12 @@ func TestTxnReadWithinUncertaintyIntervalAfterRangeMerge(t *testing.T) {
1058
1094
// - Other error (Bad) - We expect an uncertainty error so the client can choose a new timestamp and retry.
1059
1095
// - Not found (Bad) - Error because the data was written before us.
1060
1096
// - Found (Bad) - The write HLC timestamp is after our timestamp.
1061
- _ , pErr = kv .SendWrappedWith (ctx , tc .Servers [0 ].DistSenderI ().(kv.Sender ), kvpb.Header {Txn : & txn }, getArgs (keyC ))
1062
- require .IsType (t , & kvpb.ReadWithinUncertaintyIntervalError {}, pErr .GetDetail ())
1097
+ {
1098
+ ctx , fagrs := tracing .ContextWithRecordingSpan (ctx , tc .Servers [0 ].Tracer (), "txn1get-should-rwue" )
1099
+ _ , pErr := kv .SendWrappedWith (ctx , tc .Servers [0 ].DistSenderI ().(kv.Sender ), kvpb.Header {Txn : & txn }, getArgs (keyC ))
1100
+ rec := fagrs ()
1101
+ require .IsType (t , & kvpb.ReadWithinUncertaintyIntervalError {}, pErr .GetDetail (), "%s" , rec )
1102
+ }
1063
1103
}
1064
1104
1065
1105
testutils .RunTrueAndFalse (t , "alignLeaseholders" , func (t * testing.T , alignLeaseholders bool ) {
0 commit comments