diff --git a/pkg/kv/kvclient/rangefeed/rangefeed.go b/pkg/kv/kvclient/rangefeed/rangefeed.go index 83e9c88750e7..8b3e25d4de48 100644 --- a/pkg/kv/kvclient/rangefeed/rangefeed.go +++ b/pkg/kv/kvclient/rangefeed/rangefeed.go @@ -275,6 +275,7 @@ func (f *RangeFeed) maybeRunInitialScan( // indicating that the value was previously deleted. if f.withDiff { v.PrevValue = v.Value + v.PrevValue.Timestamp = hlc.Timestamp{} } // It's something of a bummer that we must allocate a new value for each diff --git a/pkg/kv/kvclient/rangefeed/rangefeed_external_test.go b/pkg/kv/kvclient/rangefeed/rangefeed_external_test.go index e31ed8ad8465..3d2d0703b065 100644 --- a/pkg/kv/kvclient/rangefeed/rangefeed_external_test.go +++ b/pkg/kv/kvclient/rangefeed/rangefeed_external_test.go @@ -88,8 +88,9 @@ func TestRangeFeedIntegration(t *testing.T) { v1 := <-rows require.Equal(t, mkKey("a"), v1.Key) // Ensure the initial scan contract is fulfilled when WithDiff is specified. - require.Equal(t, v1.Value, v1.PrevValue) + require.Equal(t, v1.Value.RawBytes, v1.PrevValue.RawBytes) require.Equal(t, v1.Value.Timestamp, afterB) + require.True(t, v1.PrevValue.Timestamp.IsEmpty()) } { v2 := <-rows diff --git a/pkg/roachpb/api.pb.go b/pkg/roachpb/api.pb.go index e13f4041dd0c..18b4015caae7 100644 --- a/pkg/roachpb/api.pb.go +++ b/pkg/roachpb/api.pb.go @@ -7130,6 +7130,7 @@ type RangeFeedValue struct { // 1. with_diff was passed in the corresponding RangeFeedRequest. // 2. the key-value was present and not a deletion tombstone before // this event. + // The timestamp on the previous value is empty. PrevValue Value `protobuf:"bytes,3,opt,name=prev_value,json=prevValue,proto3" json:"prev_value"` } diff --git a/pkg/roachpb/api.proto b/pkg/roachpb/api.proto index 248e4ce8cb1b..6e6eadf491bb 100644 --- a/pkg/roachpb/api.proto +++ b/pkg/roachpb/api.proto @@ -2385,6 +2385,7 @@ message RangeFeedValue { // 1. with_diff was passed in the corresponding RangeFeedRequest. // 2. the key-value was present and not a deletion tombstone before // this event. + // The timestamp on the previous value is empty. Value prev_value = 3 [(gogoproto.nullable) = false]; }