Upgrade versions of vendored libs
This commit is contained in:
32
vendor/github.com/cockroachdb/pebble/internal/manifest/l0_sublevels.go
generated
vendored
32
vendor/github.com/cockroachdb/pebble/internal/manifest/l0_sublevels.go
generated
vendored
@@ -714,7 +714,17 @@ func (s *L0Sublevels) InitCompactingFileInfo(inProgress []L0Compaction) {
|
||||
|
||||
iter := s.levelMetadata.Iter()
|
||||
for f := iter.First(); f != nil; f = iter.Next() {
|
||||
if !f.Compacting {
|
||||
if invariants.Enabled {
|
||||
if !bytes.Equal(s.orderedIntervals[f.minIntervalIndex].startKey.key, f.Smallest.UserKey) {
|
||||
panic(fmt.Sprintf("f.minIntervalIndex in FileMetadata out of sync with intervals in L0Sublevels: %s != %s",
|
||||
s.formatKey(s.orderedIntervals[f.minIntervalIndex].startKey.key), s.formatKey(f.Smallest.UserKey)))
|
||||
}
|
||||
if !bytes.Equal(s.orderedIntervals[f.maxIntervalIndex+1].startKey.key, f.Largest.UserKey) {
|
||||
panic(fmt.Sprintf("f.maxIntervalIndex in FileMetadata out of sync with intervals in L0Sublevels: %s != %s",
|
||||
s.formatKey(s.orderedIntervals[f.maxIntervalIndex+1].startKey.key), s.formatKey(f.Smallest.UserKey)))
|
||||
}
|
||||
}
|
||||
if !f.IsCompacting() {
|
||||
continue
|
||||
}
|
||||
for i := f.minIntervalIndex; i <= f.maxIntervalIndex; i++ {
|
||||
@@ -795,7 +805,7 @@ func (s *L0Sublevels) describe(verbose bool) string {
|
||||
}
|
||||
sumIntervals += intervals
|
||||
totalBytes += f.Size
|
||||
if f.Compacting {
|
||||
if f.IsCompacting() {
|
||||
numCompactingFiles++
|
||||
}
|
||||
}
|
||||
@@ -1042,7 +1052,7 @@ func (s *L0Sublevels) checkCompaction(c *L0CompactionFiles) error {
|
||||
fmt.Fprintf(&buf, "bug %t, seed interval: %d: level %d, sl index %d, f.index %d, min %d, max %d, pre-min %d, pre-max %d, f.min %d, f.max %d, filenum: %d, isCompacting: %t\n%s\n",
|
||||
c.isIntraL0, c.seedInterval, level, index, f.L0Index, min, max, c.preExtensionMinInterval, c.preExtensionMaxInterval,
|
||||
f.minIntervalIndex, f.maxIntervalIndex,
|
||||
f.FileNum, f.Compacting, s)
|
||||
f.FileNum, f.IsCompacting(), s)
|
||||
fmt.Fprintf(&buf, "files included:\n")
|
||||
for _, f := range c.Files {
|
||||
fmt.Fprintf(&buf, "filenum: %d, sl: %d, index: %d, [%d, %d]\n",
|
||||
@@ -1386,7 +1396,7 @@ func (s *L0Sublevels) PickBaseCompaction(
|
||||
return nil, errors.New("no seed file found in sublevel intervals")
|
||||
}
|
||||
consideredIntervals.markBits(f.minIntervalIndex, f.maxIntervalIndex+1)
|
||||
if f.Compacting {
|
||||
if f.IsCompacting() {
|
||||
if f.IsIntraL0Compacting {
|
||||
// If we're picking a base compaction and we came across a
|
||||
// seed file candidate that's being intra-L0 compacted, skip
|
||||
@@ -1418,7 +1428,7 @@ func (s *L0Sublevels) PickBaseCompaction(
|
||||
if cmp > 0 || (cmp == 0 && !s.orderedIntervals[c.maxIntervalIndex+1].startKey.isLargest) {
|
||||
break
|
||||
}
|
||||
baseCompacting = baseCompacting || m.Compacting
|
||||
baseCompacting = baseCompacting || m.IsCompacting()
|
||||
}
|
||||
if baseCompacting {
|
||||
continue
|
||||
@@ -1539,7 +1549,7 @@ func (s *L0Sublevels) extendFiles(
|
||||
if f.minIntervalIndex > cFiles.maxIntervalIndex {
|
||||
break
|
||||
}
|
||||
if f.Compacting {
|
||||
if f.IsCompacting() {
|
||||
return false
|
||||
}
|
||||
// Skip over files that are newer than earliestUnflushedSeqNum. This is
|
||||
@@ -1590,7 +1600,7 @@ func (s *L0Sublevels) PickIntraL0Compaction(
|
||||
stackDepthReduction := scoredInterval.score
|
||||
for i := len(interval.files) - 1; i >= 0; i-- {
|
||||
f = interval.files[i]
|
||||
if f.Compacting {
|
||||
if f.IsCompacting() {
|
||||
break
|
||||
}
|
||||
consideredIntervals.markBits(f.minIntervalIndex, f.maxIntervalIndex+1)
|
||||
@@ -1614,7 +1624,7 @@ func (s *L0Sublevels) PickIntraL0Compaction(
|
||||
if f == nil {
|
||||
return nil, errors.New("no seed file found in sublevel intervals")
|
||||
}
|
||||
if f.Compacting {
|
||||
if f.IsCompacting() {
|
||||
// This file could be in a concurrent intra-L0 or base compaction.
|
||||
// Try another interval.
|
||||
continue
|
||||
@@ -1666,7 +1676,7 @@ func (s *L0Sublevels) intraL0CompactionUsingSeed(
|
||||
for ; slIndex >= 0; slIndex-- {
|
||||
f2 := interval.files[slIndex]
|
||||
sl := f2.SubLevel
|
||||
if f2.Compacting {
|
||||
if f2.IsCompacting() {
|
||||
break
|
||||
}
|
||||
c.seedIntervalStackDepthReduction++
|
||||
@@ -1936,7 +1946,7 @@ func (s *L0Sublevels) extendCandidateToRectangle(
|
||||
candidateHasAlreadyPickedFiles := false
|
||||
for index = firstIndex; index <= lastIndex; index++ {
|
||||
f := files[index]
|
||||
if f.Compacting {
|
||||
if f.IsCompacting() {
|
||||
if nonCompactingFirst != -1 {
|
||||
last := index - 1
|
||||
// Prioritize runs of consecutive non-compacting files that
|
||||
@@ -1988,7 +1998,7 @@ func (s *L0Sublevels) extendCandidateToRectangle(
|
||||
}
|
||||
for index := candidateNonCompactingFirst; index <= candidateNonCompactingLast; index++ {
|
||||
f := files[index]
|
||||
if f.Compacting {
|
||||
if f.IsCompacting() {
|
||||
// TODO(bilal): Do a logger.Fatalf instead of a panic, for
|
||||
// cleaner unwinding and error messages.
|
||||
panic(fmt.Sprintf("expected %s to not be compacting", f.FileNum))
|
||||
|
||||
30
vendor/github.com/cockroachdb/pebble/internal/manifest/level_metadata.go
generated
vendored
30
vendor/github.com/cockroachdb/pebble/internal/manifest/level_metadata.go
generated
vendored
@@ -481,6 +481,21 @@ func (i *LevelIterator) SeekGE(cmp Compare, userKey []byte) *FileMetadata {
|
||||
meta := i.seek(func(m *FileMetadata) bool {
|
||||
return cmp(m.Largest.UserKey, userKey) >= 0
|
||||
})
|
||||
for meta != nil {
|
||||
switch i.filter {
|
||||
case KeyTypePointAndRange:
|
||||
return meta
|
||||
case KeyTypePoint:
|
||||
if meta.HasPointKeys && cmp(meta.LargestPointKey.UserKey, userKey) >= 0 {
|
||||
return meta
|
||||
}
|
||||
case KeyTypeRange:
|
||||
if meta.HasRangeKeys && cmp(meta.LargestRangeKey.UserKey, userKey) >= 0 {
|
||||
return meta
|
||||
}
|
||||
}
|
||||
meta = i.Next()
|
||||
}
|
||||
return i.filteredNextFile(meta)
|
||||
}
|
||||
|
||||
@@ -497,6 +512,21 @@ func (i *LevelIterator) SeekLT(cmp Compare, userKey []byte) *FileMetadata {
|
||||
return cmp(m.Smallest.UserKey, userKey) >= 0
|
||||
})
|
||||
meta := i.Prev()
|
||||
for meta != nil {
|
||||
switch i.filter {
|
||||
case KeyTypePointAndRange:
|
||||
return meta
|
||||
case KeyTypePoint:
|
||||
if meta.HasPointKeys && cmp(meta.SmallestPointKey.UserKey, userKey) < 0 {
|
||||
return meta
|
||||
}
|
||||
case KeyTypeRange:
|
||||
if meta.HasRangeKeys && cmp(meta.SmallestRangeKey.UserKey, userKey) < 0 {
|
||||
return meta
|
||||
}
|
||||
}
|
||||
meta = i.Prev()
|
||||
}
|
||||
return i.filteredPrevFile(meta)
|
||||
}
|
||||
|
||||
|
||||
130
vendor/github.com/cockroachdb/pebble/internal/manifest/version.go
generated
vendored
130
vendor/github.com/cockroachdb/pebble/internal/manifest/version.go
generated
vendored
@@ -16,6 +16,7 @@ import (
|
||||
|
||||
"github.com/cockroachdb/errors"
|
||||
"github.com/cockroachdb/pebble/internal/base"
|
||||
"github.com/cockroachdb/pebble/internal/invariants"
|
||||
"github.com/cockroachdb/pebble/vfs"
|
||||
)
|
||||
|
||||
@@ -43,15 +44,12 @@ type TableInfo struct {
|
||||
|
||||
// TableStats contains statistics on a table used for compaction heuristics.
|
||||
type TableStats struct {
|
||||
// Valid true if stats have been loaded for the table. The rest of the
|
||||
// structure is populated only if true.
|
||||
Valid bool
|
||||
// The total number of entries in the table.
|
||||
NumEntries uint64
|
||||
// The number of point and range deletion entries in the table.
|
||||
NumDeletions uint64
|
||||
// NumRangeKeys is the total number of range keys in the table.
|
||||
NumRangeKeys uint64
|
||||
// NumRangeKeySets is the total number of range key sets in the table.
|
||||
NumRangeKeySets uint64
|
||||
// Estimate of the total disk space that may be dropped by this table's
|
||||
// point deletions by compacting them.
|
||||
PointDeletionsBytesEstimate uint64
|
||||
@@ -77,6 +75,48 @@ const (
|
||||
boundTypeRangeKey
|
||||
)
|
||||
|
||||
// CompactionState is the compaction state of a file.
|
||||
//
|
||||
// The following shows the valid state transitions:
|
||||
//
|
||||
// NotCompacting --> Compacting --> Compacted
|
||||
// ^ |
|
||||
// | |
|
||||
// +-------<-------+
|
||||
//
|
||||
// Input files to a compaction transition to Compacting when a compaction is
|
||||
// picked. A file that has finished compacting typically transitions into the
|
||||
// Compacted state, at which point it is effectively obsolete ("zombied") and
|
||||
// will eventually be removed from the LSM. A file that has been move-compacted
|
||||
// will transition from Compacting back into the NotCompacting state, signaling
|
||||
// that the file may be selected for a subsequent compaction. A failed
|
||||
// compaction will result in all input tables transitioning from Compacting to
|
||||
// NotCompacting.
|
||||
//
|
||||
// This state is in-memory only. It is not persisted to the manifest.
|
||||
type CompactionState uint8
|
||||
|
||||
// CompactionStates.
|
||||
const (
|
||||
CompactionStateNotCompacting CompactionState = iota
|
||||
CompactionStateCompacting
|
||||
CompactionStateCompacted
|
||||
)
|
||||
|
||||
// String implements fmt.Stringer.
|
||||
func (s CompactionState) String() string {
|
||||
switch s {
|
||||
case CompactionStateNotCompacting:
|
||||
return "NotCompacting"
|
||||
case CompactionStateCompacting:
|
||||
return "Compacting"
|
||||
case CompactionStateCompacted:
|
||||
return "Compacted"
|
||||
default:
|
||||
panic(fmt.Sprintf("pebble: unknown compaction state %d", s))
|
||||
}
|
||||
}
|
||||
|
||||
// FileMetadata holds the metadata for an on-disk table.
|
||||
type FileMetadata struct {
|
||||
// Atomic contains fields which are accessed atomically. Go allocations
|
||||
@@ -90,6 +130,10 @@ type FileMetadata struct {
|
||||
// in pebble.Iterator after every after every positioning operation
|
||||
// that returns a user key (eg. Next, Prev, SeekGE, SeekLT, etc).
|
||||
AllowedSeeks int64
|
||||
|
||||
// statsValid is 1 if stats have been loaded for the table. The
|
||||
// TableStats structure is populated only if valid is 1.
|
||||
statsValid uint32
|
||||
}
|
||||
|
||||
// InitAllowedSeeks is the inital value of allowed seeks. This is used
|
||||
@@ -146,12 +190,11 @@ type FileMetadata struct {
|
||||
// pick L0 compactions. Only accurate for the most recent Version.
|
||||
//
|
||||
// IsIntraL0Compacting is set to True if this file is part of an intra-L0
|
||||
// compaction. When it's true, Compacting must also be true. If Compacting
|
||||
// is true and IsIntraL0Compacting is false for an L0 file, the file must
|
||||
// be part of a compaction to Lbase.
|
||||
// compaction. When it's true, IsCompacting must also return true. If
|
||||
// Compacting is true and IsIntraL0Compacting is false for an L0 file, the
|
||||
// file must be part of a compaction to Lbase.
|
||||
IsIntraL0Compacting bool
|
||||
// True if the file is actively being compacted. Protected by DB.mu.
|
||||
Compacting bool
|
||||
CompactionState CompactionState
|
||||
// True if compaction of this file has been explicitly requested.
|
||||
// Previously, RocksDB and earlier versions of Pebble allowed this
|
||||
// flag to be set by a user table property collector. Some earlier
|
||||
@@ -169,9 +212,11 @@ type FileMetadata struct {
|
||||
//
|
||||
// Protected by DB.mu.
|
||||
MarkedForCompaction bool
|
||||
// HasPointKeys and HasRangeKeys track whether the table contains point and
|
||||
// range keys, respectively.
|
||||
// HasPointKeys tracks whether the table contains point keys (including
|
||||
// RANGEDELs). If a table contains only range deletions, HasPointsKeys is
|
||||
// still true.
|
||||
HasPointKeys bool
|
||||
// HasRangeKeys tracks whether the table contains any range keys.
|
||||
HasRangeKeys bool
|
||||
// smallestSet and largestSet track whether the overall bounds have been set.
|
||||
boundsSet bool
|
||||
@@ -181,6 +226,59 @@ type FileMetadata struct {
|
||||
boundTypeSmallest, boundTypeLargest boundType
|
||||
}
|
||||
|
||||
// SetCompactionState transitions this file's compaction state to the given
|
||||
// state. Protected by DB.mu.
|
||||
func (m *FileMetadata) SetCompactionState(to CompactionState) {
|
||||
if invariants.Enabled {
|
||||
transitionErr := func() error {
|
||||
return errors.Newf("pebble: invalid compaction state transition: %s -> %s", m.CompactionState, to)
|
||||
}
|
||||
switch m.CompactionState {
|
||||
case CompactionStateNotCompacting:
|
||||
if to != CompactionStateCompacting {
|
||||
panic(transitionErr())
|
||||
}
|
||||
case CompactionStateCompacting:
|
||||
if to != CompactionStateCompacted && to != CompactionStateNotCompacting {
|
||||
panic(transitionErr())
|
||||
}
|
||||
case CompactionStateCompacted:
|
||||
panic(transitionErr())
|
||||
default:
|
||||
panic(fmt.Sprintf("pebble: unknown compaction state: %d", m.CompactionState))
|
||||
}
|
||||
}
|
||||
m.CompactionState = to
|
||||
}
|
||||
|
||||
// IsCompacting returns true if this file's compaction state is
|
||||
// CompactionStateCompacting. Protected by DB.mu.
|
||||
func (m *FileMetadata) IsCompacting() bool {
|
||||
return m.CompactionState == CompactionStateCompacting
|
||||
}
|
||||
|
||||
// StatsValid returns true if the table stats have been populated. If StatValid
|
||||
// returns true, the Stats field may be read (with or without holding the
|
||||
// database mutex).
|
||||
func (m *FileMetadata) StatsValid() bool {
|
||||
return atomic.LoadUint32(&m.Atomic.statsValid) == 1
|
||||
}
|
||||
|
||||
// StatsValidLocked returns true if the table stats have been populated.
|
||||
// StatsValidLocked requires DB.mu is held when it's invoked, and it avoids the
|
||||
// overhead of an atomic load. This is possible because table stats validity is
|
||||
// only set while DB.mu is held.
|
||||
func (m *FileMetadata) StatsValidLocked() bool {
|
||||
return m.Atomic.statsValid == 1
|
||||
}
|
||||
|
||||
// StatsMarkValid marks the TableStats as valid. The caller must hold DB.mu
|
||||
// while populating TableStats and calling StatsMarkValud. Once stats are
|
||||
// populated, they must not be mutated.
|
||||
func (m *FileMetadata) StatsMarkValid() {
|
||||
atomic.StoreUint32(&m.Atomic.statsValid, 1)
|
||||
}
|
||||
|
||||
// ExtendPointKeyBounds attempts to extend the lower and upper point key bounds
|
||||
// and overall table bounds with the given smallest and largest keys. The
|
||||
// smallest and largest bounds may not be extended if the table already has a
|
||||
@@ -654,6 +752,11 @@ type Version struct {
|
||||
|
||||
Levels [NumLevels]LevelMetadata
|
||||
|
||||
// RangeKeyLevels holds a subset of the same files as Levels that contain range
|
||||
// keys (i.e. fileMeta.HasRangeKeys == true). The memory amplification of this
|
||||
// duplication should be minimal, as range keys are expected to be rare.
|
||||
RangeKeyLevels [NumLevels]LevelMetadata
|
||||
|
||||
// The callback to invoke when the last reference to a version is
|
||||
// removed. Will be called with list.mu held.
|
||||
Deleted func(obsolete []*FileMetadata)
|
||||
@@ -787,6 +890,9 @@ func (v *Version) unrefFiles() []*FileMetadata {
|
||||
for _, lm := range v.Levels {
|
||||
obsolete = append(obsolete, lm.release()...)
|
||||
}
|
||||
for _, lm := range v.RangeKeyLevels {
|
||||
obsolete = append(obsolete, lm.release()...)
|
||||
}
|
||||
return obsolete
|
||||
}
|
||||
|
||||
|
||||
22
vendor/github.com/cockroachdb/pebble/internal/manifest/version_edit.go
generated
vendored
22
vendor/github.com/cockroachdb/pebble/internal/manifest/version_edit.go
generated
vendored
@@ -648,6 +648,11 @@ func (b *BulkVersionEdit) Apply(
|
||||
} else {
|
||||
v.Levels[level] = curr.Levels[level].clone()
|
||||
}
|
||||
if curr == nil || curr.RangeKeyLevels[level].tree.root == nil {
|
||||
v.RangeKeyLevels[level] = makeLevelMetadata(cmp, level, nil /* files */)
|
||||
} else {
|
||||
v.RangeKeyLevels[level] = curr.RangeKeyLevels[level].clone()
|
||||
}
|
||||
|
||||
if len(b.Added[level]) == 0 && len(b.Deleted[level]) == 0 {
|
||||
// There are no edits on this level.
|
||||
@@ -667,6 +672,7 @@ func (b *BulkVersionEdit) Apply(
|
||||
|
||||
// Some edits on this level.
|
||||
lm := &v.Levels[level]
|
||||
lmRange := &v.RangeKeyLevels[level]
|
||||
addedFiles := b.Added[level]
|
||||
deletedMap := b.Deleted[level]
|
||||
if n := v.Levels[level].Len() + len(addedFiles); n == 0 {
|
||||
@@ -688,6 +694,16 @@ func (b *BulkVersionEdit) Apply(
|
||||
err := errors.Errorf("pebble: internal error: file L%d.%s obsolete during B-Tree removal", level, f.FileNum)
|
||||
return nil, nil, err
|
||||
}
|
||||
if f.HasRangeKeys {
|
||||
if obsolete := v.RangeKeyLevels[level].tree.delete(f); obsolete {
|
||||
// Deleting a file from the B-Tree may decrement its
|
||||
// reference count. However, because we cloned the
|
||||
// previous level's B-Tree, this should never result in a
|
||||
// file's reference count dropping to zero.
|
||||
err := errors.Errorf("pebble: internal error: file L%d.%s obsolete during range-key B-Tree removal", level, f.FileNum)
|
||||
return nil, nil, err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var sm, la *FileMetadata
|
||||
@@ -714,6 +730,12 @@ func (b *BulkVersionEdit) Apply(
|
||||
if err != nil {
|
||||
return nil, nil, errors.Wrap(err, "pebble")
|
||||
}
|
||||
if f.HasRangeKeys {
|
||||
err = lmRange.tree.insert(f)
|
||||
if err != nil {
|
||||
return nil, nil, errors.Wrap(err, "pebble")
|
||||
}
|
||||
}
|
||||
removeZombie(f.FileNum)
|
||||
// Track the keys with the smallest and largest keys, so that we can
|
||||
// check consistency of the modified span.
|
||||
|
||||
Reference in New Issue
Block a user