Skip to content

Commit

Permalink
feat(dropPrefix): add DropPrefixNonBlocking API (dgraph-io#1698)
Browse files Browse the repository at this point in the history
This PR adds DropPrefixNonBlocking and DropPrefixBlocking API that can be used to logically delete the data for specified prefixes.
DropPrefix now makes decision based on badger option AllowStopTheWorld whose default is to use DropPrefixBlocking.
With DropPrefixNonBlocking the data would not be cleared from the LSM tree immediately. It would be deleted eventually through compactions.

Co-authored-by: Rohan Prasad <[email protected]>
  • Loading branch information
2 people authored and fredcarle committed Aug 1, 2023
1 parent 6bac2a1 commit 2f7100e
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions options.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ type Options struct {
// ChecksumVerificationMode decides when db should verify checksums for SSTable blocks.
ChecksumVerificationMode options.ChecksumVerificationMode

// AllowStopTheWorld determines whether the DropPrefix will be blocking/non-blocking.
AllowStopTheWorld bool

// DetectConflicts determines whether the transactions would be checked for
// conflicts. The transactions can be processed at a higher rate when
// conflict detection is disabled.
Expand Down Expand Up @@ -146,6 +149,7 @@ func DefaultOptions(path string) Options {
MaxLevels: 7,
NumGoroutines: 8,
MetricsEnabled: true,
AllowStopTheWorld: true,

NumCompactors: 4, // Run at least 2 compactors. Zero-th compactor prioritizes L0.
NumLevelZeroTables: 5,
Expand Down Expand Up @@ -684,6 +688,20 @@ func (opt Options) WithChecksumVerificationMode(cvMode options.ChecksumVerificat
return opt
}

// WithAllowStopTheWorld returns a new Options value with AllowStopTheWorld set to the given value.
//
// AllowStopTheWorld indicates whether the call to DropPrefix should block the writes or not.
// When set to false, the DropPrefix will do a logical delete and will not block
// the writes. Although, this will not immediately clear up the LSM tree.
// When set to false, the DropPrefix will block the writes and will clear up the LSM
// tree.
//
// The default value of AllowStopTheWorld is true.
func (opt Options) WithAllowStopTheWorld(b bool) Options {
opt.AllowStopTheWorld = b
return opt
}

// WithBlockCacheSize returns a new Options value with BlockCacheSize set to the given value.
//
// This value specifies how much data cache should hold in memory. A small size
Expand Down

0 comments on commit 2f7100e

Please sign in to comment.