Upgrade versions of vendored libs
This commit is contained in:
25
vendor/github.com/cockroachdb/pebble/mem_table.go
generated
vendored
25
vendor/github.com/cockroachdb/pebble/mem_table.go
generated
vendored
@@ -80,7 +80,7 @@ type memTable struct {
|
||||
// inflight mutations that have reserved space in the memtable but not yet
|
||||
// applied. The memtable cannot be flushed to disk until the writer refs
|
||||
// drops to zero.
|
||||
writerRefs int32
|
||||
writerRefs atomic.Int32
|
||||
tombstones keySpanCache
|
||||
rangeKeys keySpanCache
|
||||
// The current logSeqNum at the time the memtable was created. This is
|
||||
@@ -115,13 +115,13 @@ func newMemTable(opts memTableOptions) *memTable {
|
||||
}
|
||||
|
||||
m := &memTable{
|
||||
cmp: opts.Comparer.Compare,
|
||||
formatKey: opts.Comparer.FormatKey,
|
||||
equal: opts.Comparer.Equal,
|
||||
arenaBuf: opts.arenaBuf,
|
||||
writerRefs: 1,
|
||||
logSeqNum: opts.logSeqNum,
|
||||
cmp: opts.Comparer.Compare,
|
||||
formatKey: opts.Comparer.FormatKey,
|
||||
equal: opts.Comparer.Equal,
|
||||
arenaBuf: opts.arenaBuf,
|
||||
logSeqNum: opts.logSeqNum,
|
||||
}
|
||||
m.writerRefs.Store(1)
|
||||
m.tombstones = keySpanCache{
|
||||
cmp: m.cmp,
|
||||
formatKey: m.formatKey,
|
||||
@@ -143,18 +143,19 @@ func newMemTable(opts memTableOptions) *memTable {
|
||||
m.skl.Reset(arena, m.cmp)
|
||||
m.rangeDelSkl.Reset(arena, m.cmp)
|
||||
m.rangeKeySkl.Reset(arena, m.cmp)
|
||||
m.reserved = arena.Size()
|
||||
return m
|
||||
}
|
||||
|
||||
func (m *memTable) writerRef() {
|
||||
switch v := atomic.AddInt32(&m.writerRefs, 1); {
|
||||
switch v := m.writerRefs.Add(1); {
|
||||
case v <= 1:
|
||||
panic(fmt.Sprintf("pebble: inconsistent reference count: %d", v))
|
||||
}
|
||||
}
|
||||
|
||||
func (m *memTable) writerUnref() bool {
|
||||
switch v := atomic.AddInt32(&m.writerRefs, -1); {
|
||||
switch v := m.writerRefs.Add(-1); {
|
||||
case v < 0:
|
||||
panic(fmt.Sprintf("pebble: inconsistent reference count: %d", v))
|
||||
case v == 0:
|
||||
@@ -165,7 +166,7 @@ func (m *memTable) writerUnref() bool {
|
||||
}
|
||||
|
||||
func (m *memTable) readyForFlush() bool {
|
||||
return atomic.LoadInt32(&m.writerRefs) == 0
|
||||
return m.writerRefs.Load() == 0
|
||||
}
|
||||
|
||||
// Prepare reserves space for the batch in the memtable and references the
|
||||
@@ -210,6 +211,8 @@ func (m *memTable) apply(batch *Batch, seqNum uint64) error {
|
||||
// Don't increment seqNum for LogData, since these are not applied
|
||||
// to the memtable.
|
||||
seqNum--
|
||||
case InternalKeyKindIngestSST:
|
||||
panic("pebble: cannot apply ingested sstable key kind to memtable")
|
||||
default:
|
||||
err = ins.Add(&m.skl, ikey, value)
|
||||
}
|
||||
@@ -263,7 +266,7 @@ func (m *memTable) containsRangeKeys() bool {
|
||||
|
||||
func (m *memTable) availBytes() uint32 {
|
||||
a := m.skl.Arena()
|
||||
if atomic.LoadInt32(&m.writerRefs) == 1 {
|
||||
if m.writerRefs.Load() == 1 {
|
||||
// If there are no other concurrent apply operations, we can update the
|
||||
// reserved bytes setting to accurately reflect how many bytes of been
|
||||
// allocated vs the over-estimation present in memTableEntrySize.
|
||||
|
||||
Reference in New Issue
Block a user