Skip to content

Commit

Permalink
Retry removing lock file
Browse files Browse the repository at this point in the history
  • Loading branch information
RebeccaMahany committed Dec 17, 2024
1 parent a833edf commit 2c83441
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion pkg/osquery/runtime/osqueryinstance.go
Original file line number Diff line number Diff line change
Expand Up @@ -720,7 +720,15 @@ func (i *OsqueryInstance) cleanUpOldDatabaseLock(ctx context.Context, paths *osq
return nil
}

if err := os.Remove(lockFilePath); err != nil {
// We do a couple retries here -- Windows complains about removing files in use sometimes.
err = backoff.WaitFor(func() error {
if err := os.Remove(lockFilePath); err != nil {
return fmt.Errorf("removing lock file at %s: %w", lockFilePath, err)
}
return nil
}, 5*time.Second, 500*time.Millisecond)

if err != nil {
i.slogger.Log(ctx, slog.LevelInfo,
"detected old lock file but could not remove it",
"lockfile_path", lockFilePath,
Expand Down

0 comments on commit 2c83441

Please sign in to comment.