Skip to content

Commit

Permalink
rangefeed: omit timestamps on previous values
Browse files Browse the repository at this point in the history
There was a discrepancy with whether or not the previous contained the
timestamp of when the previous value was recorded. With the initial
scan, we populated the timestamp of the initial scan itself. With
regular diffs, we omitted the timestamp. This made for confusing
semantics (well, confusing at least for this author).

Release note: None
  • Loading branch information
irfansharif committed Oct 14, 2021
1 parent b7a0e52 commit 99c5df4
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions pkg/kv/kvclient/rangefeed/rangefeed.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion pkg/kv/kvclient/rangefeed/rangefeed_external_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions pkg/roachpb/api.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pkg/roachpb/api.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}

Expand Down

0 comments on commit 99c5df4

Please sign in to comment.