Skip to content

Commit

Permalink
tool: add DirectoryLock option
Browse files Browse the repository at this point in the history
Add a new DirectoryLock option so that users of the tool package's programmatic
interface may pass an already-acquired directory lock to Pebble. In
CockroachDB, we acquire the directory lock before opening Open in order to
prevent concurrent modification of the encryption-at-rest state.
  • Loading branch information
jbowens committed Mar 12, 2024
1 parent ec69e9a commit 51faab0
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tool/tool.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,18 @@ func Filters(filters ...FilterPolicy) Option {
}
}

// DirectoryLock may be passed to New to pass an existing file lock within a
// data directory. Some tool options open the database and will acquire the
// directory's file lock if not already held. If the caller has already acquired
// the file lock, they may pass it here. When the tool is embedded within the
// CockroachDB CLI, we do this to ensure the lock provides mutual exclusion over
// the persistent encryption-at-rest state.
func DirectoryLock(lock *pebble.Lock) Option {
return func(t *T) {
t.opts.Lock = lock
}
}

// FS sets the filesystem implementation to use by the introspection tools.
func FS(fs vfs.FS) Option {
return func(t *T) {
Expand Down

0 comments on commit 51faab0

Please sign in to comment.