MCPcopy
hub / github.com/dgraph-io/badger / DropAll

Method DropAll

db.go:1558–1564  ·  view source on GitHub ↗

DropAll would drop all the data stored in Badger. It does this in the following way. - Stop accepting new writes. - Pause memtable flushes and compactions. - Pick all tables from all levels, create a changeset to delete all these tables and apply it to manifest. - Pick all log files from value log,

()

Source from the content-addressed store, hash-verified

1556// any reads while DropAll is going on, otherwise they may result in panics. Ideally, both reads and
1557// writes are paused before running DropAll, and resumed after it is finished.
1558func (db *DB) DropAll() error {
1559 f, err := db.dropAll()
1560 if f != nil {
1561 f()
1562 }
1563 return err
1564}
1565
1566func (db *DB) dropAll() (func(), error) {
1567 db.opt.Infof("DropAll called. Blocking writes...")

Callers 8

runTestFunction · 0.95
TestDropAllManagedFunction · 0.80
TestDropAllFunction · 0.80
TestDropAllTwiceFunction · 0.80
TestDropReadOnlyFunction · 0.80
TestDropAllRaceFunction · 0.80
TestDropAllDropPrefixFunction · 0.80

Calls 1

dropAllMethod · 0.95

Tested by 7

TestDropAllManagedFunction · 0.64
TestDropAllFunction · 0.64
TestDropAllTwiceFunction · 0.64
TestDropReadOnlyFunction · 0.64
TestDropAllRaceFunction · 0.64
TestDropAllDropPrefixFunction · 0.64