Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

release-24.2: storage: set correct key in WriteTooOld error from pebbleMVCCScanner #131329

Merged
merged 1 commit into from
Oct 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 5 additions & 8 deletions pkg/storage/pebble_mvcc_scanner.go
Original file line number Diff line number Diff line change
Expand Up @@ -850,9 +850,8 @@ func (p *pebbleMVCCScanner) getOne(ctx context.Context) (ok, added bool) {
// timestamp with the maximum timestamp we've seen so we know to
// return an error, but then keep scanning so that we can return
// the largest possible time.
p.mostRecentTS.Forward(p.curUnsafeKey.Timestamp)
if len(p.mostRecentKey) == 0 {
p.mostRecentKey = append(p.mostRecentKey, p.curUnsafeKey.Key...)
if p.mostRecentTS.Forward(p.curUnsafeKey.Timestamp) {
p.mostRecentKey = append(p.mostRecentKey[:0], p.curUnsafeKey.Key...)
}
return true /* ok */, false
}
Expand Down Expand Up @@ -883,9 +882,8 @@ func (p *pebbleMVCCScanner) getOne(ctx context.Context) (ok, added bool) {
// timestamp with the maximum timestamp we've seen so we know to
// return an error, but then keep scanning so that we can return
// the largest possible time.
p.mostRecentTS.Forward(p.curUnsafeKey.Timestamp)
if len(p.mostRecentKey) == 0 {
p.mostRecentKey = append(p.mostRecentKey, p.curUnsafeKey.Key...)
if p.mostRecentTS.Forward(p.curUnsafeKey.Timestamp) {
p.mostRecentKey = append(p.mostRecentKey[:0], p.curUnsafeKey.Key...)
}
return true /* ok */, false
}
Expand Down Expand Up @@ -1521,8 +1519,7 @@ func (p *pebbleMVCCScanner) processRangeKeys(seeked bool, reverse bool) bool {
if p.failOnMoreRecent {
if key := p.parent.UnsafeKey(); !hasPoint || !key.Timestamp.IsEmpty() {
if newest := p.curRangeKeys.Newest(); p.ts.LessEq(newest) {
p.mostRecentTS.Forward(newest)
if len(p.mostRecentKey) == 0 {
if p.mostRecentTS.Forward(newest) {
p.mostRecentKey = append(p.mostRecentKey[:0], key.Key...)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ run error
scan k=a end=d ts=3 failOnMoreRecent
----
scan: "a"-"d" -> <no data>
error: (*kvpb.WriteTooOldError:) WriteTooOldError: write for key "a" at timestamp 3.000000000,0 too old; must write at or above 4.000000000,1
error: (*kvpb.WriteTooOldError:) WriteTooOldError: write for key "c" at timestamp 3.000000000,0 too old; must write at or above 4.000000000,1

run error
scan k=a end=d ts=4 failOnMoreRecent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,13 +242,13 @@ run error
scan k=a end=b_next ts=9,0 failOnMoreRecent
----
scan: "a"-"b_next" -> <no data>
error: (*kvpb.WriteTooOldError:) WriteTooOldError: write for key "a" at timestamp 9.000000000,0 too old; must write at or above 13.000000000,1
error: (*kvpb.WriteTooOldError:) WriteTooOldError: write for key "b" at timestamp 9.000000000,0 too old; must write at or above 13.000000000,1

run error
scan k=a end=c_next ts=9,0 failOnMoreRecent
----
scan: "a"-"c_next" -> <no data>
error: (*kvpb.WriteTooOldError:) WriteTooOldError: write for key "a" at timestamp 9.000000000,0 too old; must write at or above 13.000000000,1
error: (*kvpb.WriteTooOldError:) WriteTooOldError: write for key "b" at timestamp 9.000000000,0 too old; must write at or above 13.000000000,1

run error
scan k=b end=c_next ts=9,0 failOnMoreRecent
Expand Down
20 changes: 10 additions & 10 deletions pkg/storage/testdata/mvcc_histories/skip_locked
Original file line number Diff line number Diff line change
Expand Up @@ -764,13 +764,13 @@ run error
scan ts=10 k=k1 end=k9 skipLocked failOnMoreRecent str=shared
----
scan: "k1"-"k9" -> <no data>
error: (*kvpb.WriteTooOldError:) WriteTooOldError: write for key "k1" at timestamp 10.000000000,0 too old; must write at or above 17.000000000,1
error: (*kvpb.WriteTooOldError:) WriteTooOldError: write for key "k5" at timestamp 10.000000000,0 too old; must write at or above 17.000000000,1

run error
scan ts=10 k=k1 end=k9 reverse skipLocked failOnMoreRecent str=shared
----
scan: "k1"-"k9" -> <no data>
error: (*kvpb.WriteTooOldError:) WriteTooOldError: write for key "k6" at timestamp 10.000000000,0 too old; must write at or above 17.000000000,1
error: (*kvpb.WriteTooOldError:) WriteTooOldError: write for key "k5" at timestamp 10.000000000,0 too old; must write at or above 17.000000000,1

run error
get ts=11 k=k1 skipLocked failOnMoreRecent str=shared
Expand Down Expand Up @@ -812,13 +812,13 @@ run error
scan ts=11 k=k1 end=k9 skipLocked failOnMoreRecent str=shared
----
scan: "k1"-"k9" -> <no data>
error: (*kvpb.WriteTooOldError:) WriteTooOldError: write for key "k1" at timestamp 11.000000000,0 too old; must write at or above 17.000000000,1
error: (*kvpb.WriteTooOldError:) WriteTooOldError: write for key "k5" at timestamp 11.000000000,0 too old; must write at or above 17.000000000,1

run error
scan ts=11 k=k1 end=k9 reverse skipLocked failOnMoreRecent str=shared
----
scan: "k1"-"k9" -> <no data>
error: (*kvpb.WriteTooOldError:) WriteTooOldError: write for key "k6" at timestamp 11.000000000,0 too old; must write at or above 17.000000000,1
error: (*kvpb.WriteTooOldError:) WriteTooOldError: write for key "k5" at timestamp 11.000000000,0 too old; must write at or above 17.000000000,1

run ok
get ts=12 k=k1 skipLocked failOnMoreRecent str=shared
Expand Down Expand Up @@ -865,7 +865,7 @@ run error
scan ts=12 k=k1 end=k9 reverse skipLocked failOnMoreRecent str=shared
----
scan: "k1"-"k9" -> <no data>
error: (*kvpb.WriteTooOldError:) WriteTooOldError: write for key "k6" at timestamp 12.000000000,0 too old; must write at or above 17.000000000,1
error: (*kvpb.WriteTooOldError:) WriteTooOldError: write for key "k5" at timestamp 12.000000000,0 too old; must write at or above 17.000000000,1

run ok
get ts=12 t=A k=k1 skipLocked failOnMoreRecent str=shared
Expand Down Expand Up @@ -912,7 +912,7 @@ run error
scan ts=12 t=A k=k1 end=k9 reverse skipLocked failOnMoreRecent str=shared
----
scan: "k1"-"k9" -> <no data>
error: (*kvpb.WriteTooOldError:) WriteTooOldError: write for key "k6" at timestamp 12.000000000,0 too old; must write at or above 17.000000000,1
error: (*kvpb.WriteTooOldError:) WriteTooOldError: write for key "k5" at timestamp 12.000000000,0 too old; must write at or above 17.000000000,1

run ok
get ts=13 k=k1 skipLocked failOnMoreRecent str=shared
Expand Down Expand Up @@ -959,7 +959,7 @@ run error
scan ts=13 k=k1 end=k9 reverse skipLocked failOnMoreRecent str=shared
----
scan: "k1"-"k9" -> <no data>
error: (*kvpb.WriteTooOldError:) WriteTooOldError: write for key "k6" at timestamp 13.000000000,0 too old; must write at or above 17.000000000,1
error: (*kvpb.WriteTooOldError:) WriteTooOldError: write for key "k5" at timestamp 13.000000000,0 too old; must write at or above 17.000000000,1

run ok
get ts=13 t=B k=k1 skipLocked failOnMoreRecent str=shared
Expand Down Expand Up @@ -1005,7 +1005,7 @@ run error
scan ts=13 t=B k=k1 end=k9 reverse skipLocked failOnMoreRecent str=shared
----
scan: "k1"-"k9" -> <no data>
error: (*kvpb.WriteTooOldError:) WriteTooOldError: write for key "k6" at timestamp 13.000000000,0 too old; must write at or above 17.000000000,1
error: (*kvpb.WriteTooOldError:) WriteTooOldError: write for key "k5" at timestamp 13.000000000,0 too old; must write at or above 17.000000000,1

run ok
get ts=14 k=k1 skipLocked failOnMoreRecent str=shared
Expand Down Expand Up @@ -1424,7 +1424,7 @@ run error
scan ts=10 k=k1 end=k9 skipLocked failOnMoreRecent str=exclusive
----
scan: "k1"-"k9" -> <no data>
error: (*kvpb.WriteTooOldError:) WriteTooOldError: write for key "k1" at timestamp 10.000000000,0 too old; must write at or above 17.000000000,1
error: (*kvpb.WriteTooOldError:) WriteTooOldError: write for key "k5" at timestamp 10.000000000,0 too old; must write at or above 17.000000000,1

run error
scan ts=10 k=k1 end=k9 reverse skipLocked failOnMoreRecent str=exclusive
Expand Down Expand Up @@ -1472,7 +1472,7 @@ run error
scan ts=11 k=k1 end=k9 skipLocked failOnMoreRecent str=exclusive
----
scan: "k1"-"k9" -> <no data>
error: (*kvpb.WriteTooOldError:) WriteTooOldError: write for key "k1" at timestamp 11.000000000,0 too old; must write at or above 17.000000000,1
error: (*kvpb.WriteTooOldError:) WriteTooOldError: write for key "k5" at timestamp 11.000000000,0 too old; must write at or above 17.000000000,1

run error
scan ts=11 k=k1 end=k9 reverse skipLocked failOnMoreRecent str=exclusive
Expand Down