Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions go/store/nbs/file_manifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,10 @@ import (
)

const (
manifestFileName = "manifest"
lockFileName = "LOCK"
lockFileTimeout = time.Millisecond * 100
manifestFileName = "manifest"
lockFileName = "LOCK"
lockFileTimeout = time.Millisecond * 100
lockRetryInterval = time.Millisecond * 10

storageVersion4 = "4"

Expand Down
11 changes: 10 additions & 1 deletion go/store/nbs/journal.go
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,12 @@ func newJournalManifest(ctx context.Context, dir string, opts JournalingStoreOpt
// try to take the file lock. if we fail, make the manifest read-only.
// if we succeed, hold the file lock until we close the journalManifest
if opts.BlockOnLock {
var ticker *time.Ticker
defer func() {
if ticker != nil {
ticker.Stop()
}
}()
for {
err = lock.TryLock()
if err == nil {
Expand All @@ -564,10 +570,13 @@ func newJournalManifest(ctx context.Context, dir string, opts JournalingStoreOpt
if !errors.Is(err, fslock.ErrLocked) {
return nil, err
}
if ticker == nil {
ticker = time.NewTicker(lockRetryInterval)
}
select {
case <-ctx.Done():
return nil, ctx.Err()
case <-time.After(10 * time.Millisecond):
case <-ticker.C:
}
}
} else {
Expand Down