Skip to content

Commit 2b93727

Browse files
Revert "fix(skiplist-handler): Iterate over skiplist and send updates to publisher (#1697)"
This reverts commit e4002b7.
1 parent b1d1b27 commit 2b93727

File tree

3 files changed

+18
-36
lines changed

3 files changed

+18
-36
lines changed

db.go

Lines changed: 16 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -941,7 +941,8 @@ func (db *DB) doWrites(lc *z.Closer) {
941941

942942
// batchSet applies a list of badger.Entry. If a request level error occurs it
943943
// will be returned.
944-
// Check(kv.BatchSet(entries))
944+
//
945+
// Check(kv.BatchSet(entries))
945946
func (db *DB) batchSet(entries []*Entry) error {
946947
req, err := db.sendToWriteCh(entries)
947948
if err != nil {
@@ -954,9 +955,10 @@ func (db *DB) batchSet(entries []*Entry) error {
954955
// batchSetAsync is the asynchronous version of batchSet. It accepts a callback
955956
// function which is called when all the sets are complete. If a request level
956957
// error occurs, it will be passed back via the callback.
957-
// err := kv.BatchSetAsync(entries, func(err error)) {
958-
// Check(err)
959-
// }
958+
//
959+
// err := kv.BatchSetAsync(entries, func(err error)) {
960+
// Check(err)
961+
// }
960962
func (db *DB) batchSetAsync(entries []*Entry, f func(error)) error {
961963
req, err := db.sendToWriteCh(entries)
962964
if err != nil {
@@ -1028,26 +1030,6 @@ func (db *DB) HandoverSkiplist(skl *skl.Skiplist, callback func()) error {
10281030

10291031
mt := &memTable{sl: skl}
10301032

1031-
// Iterate over the skiplist and send the entries to the publisher.
1032-
it := skl.NewIterator()
1033-
1034-
var entries []*Entry
1035-
for it.SeekToFirst(); it.Valid(); it.Next() {
1036-
v := it.Value()
1037-
e := &Entry{
1038-
Key: it.Key(),
1039-
Value: v.Value,
1040-
ExpiresAt: v.ExpiresAt,
1041-
UserMeta: v.UserMeta,
1042-
}
1043-
entries = append(entries, e)
1044-
}
1045-
req := &request{
1046-
Entries: entries,
1047-
}
1048-
reqs := []*request{req}
1049-
db.pub.sendUpdates(reqs)
1050-
10511033
select {
10521034
case db.flushChan <- flushTask{mt: mt, cb: callback}:
10531035
db.imm = append(db.imm, mt)
@@ -1945,16 +1927,16 @@ func (db *DB) DropPrefix(prefixes ...[]byte) error {
19451927
}
19461928

19471929
// DropPrefix would drop all the keys with the provided prefix. It does this in the following way:
1948-
// - Stop accepting new writes.
1949-
// - Stop memtable flushes before acquiring lock. Because we're acquring lock here
1950-
// and memtable flush stalls for lock, which leads to deadlock
1951-
// - Flush out all memtables, skipping over keys with the given prefix, Kp.
1952-
// - Write out the value log header to memtables when flushing, so we don't accidentally bring Kp
1953-
// back after a restart.
1954-
// - Stop compaction.
1955-
// - Compact L0->L1, skipping over Kp.
1956-
// - Compact rest of the levels, Li->Li, picking tables which have Kp.
1957-
// - Resume memtable flushes, compactions and writes.
1930+
// - Stop accepting new writes.
1931+
// - Stop memtable flushes before acquiring lock. Because we're acquring lock here
1932+
// and memtable flush stalls for lock, which leads to deadlock
1933+
// - Flush out all memtables, skipping over keys with the given prefix, Kp.
1934+
// - Write out the value log header to memtables when flushing, so we don't accidentally bring Kp
1935+
// back after a restart.
1936+
// - Stop compaction.
1937+
// - Compact L0->L1, skipping over Kp.
1938+
// - Compact rest of the levels, Li->Li, picking tables which have Kp.
1939+
// - Resume memtable flushes, compactions and writes.
19581940
func (db *DB) DropPrefixBlocking(prefixes ...[]byte) error {
19591941
if len(prefixes) == 0 {
19601942
return nil

db2_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -996,7 +996,7 @@ func TestKeyCount(t *testing.T) {
996996
}()
997997

998998
write := func(kvs *pb.KVList) error {
999-
buf := z.NewBuffer(1<<20, "test")
999+
buf := z.NewBuffer(1 << 20, "test")
10001000
defer buf.Release()
10011001

10021002
for _, kv := range kvs.Kv {

db_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2134,7 +2134,7 @@ func TestMain(m *testing.M) {
21342134

21352135
func removeDir(dir string) {
21362136
if err := os.RemoveAll(dir); err != nil {
2137-
fmt.Printf("Error while removing dir: %v\n", err)
2137+
panic(err)
21382138
}
21392139
}
21402140

0 commit comments

Comments
 (0)