forked from cockroachdb/cockroach
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
kvserver: avoid spanset assertion in MVCCGarbageCollect
See cockroachdb#80619 (comment). My understanding is that in `MVCCGarbageCollect`, we look at each `key`. First, we seek the iterator to construct the `MVCCMetadata` (if there is one), so we're here: ``` key @ ts=100 <-- iter key @ ts=099 ... key @ ts=007 key @ ts=006 key @ ts=005 ``` If we want to GC at timestamp, say, 6, we need to iterate forwards. To avoid calling `Next()` too many times, eventually we'll instead `SeekLT(key @ 6)`. But we only hold the latch for `key`, so we can't seek into `[/Min, key)`. Disable the spanset assertions here. We use the result of `SeekLT` only if it puts us into keyspace covered by the latch. An import cycle (spanset - storage - spanset) made this require a small refactor. Release note: None
- Loading branch information
Showing
6 changed files
with
57 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Copyright 2022 The Cockroach Authors. | ||
// | ||
// Use of this software is governed by the Business Source License | ||
// included in the file licenses/BSL.txt. | ||
// | ||
// As of the Change Date specified in that file, in accordance with | ||
// the Business Source License, use of this software will be governed | ||
// by the Apache License, Version 2.0, included in the file | ||
// licenses/APL.txt. | ||
// | ||
|
||
package storage | ||
|
||
// DisableReaderAssertionsI is optionally implemented by arguments to DisableReaderAssertions. | ||
type DisableReaderAssertionsI interface { | ||
DisableReaderAssertions() (wrapped Reader) | ||
} | ||
|
||
// DisableReaderAssertions unwraps any storage.Reader implementations that may | ||
// assert access against a given SpanSet. | ||
func DisableReaderAssertions(reader Reader) Reader { | ||
switch v := reader.(type) { | ||
case DisableReaderAssertionsI: | ||
return DisableReaderAssertions(v.DisableReaderAssertions()) | ||
default: | ||
return reader | ||
} | ||
} |