Skip to content

Use LockFile for directory locking on windows #1364

@jarifibrahim

Description

@jarifibrahim

Badger acquires an exclusive lock on the directory to prevent multiple processes from using it. The existing code in dir_windows.go file relies on an in-memory handle to prevent multiple files from accessing it.
https://github.com/dgraph-io/badger/blob/14386ac9b764cb6655cb0da7c848e244369a2a27/dir_windows.go#L82-L98

While opening we set the sharing mode to zero which means only one process can access it
From Create File Documentation

If this parameter is zero and CreateFile succeeds, the file or device cannot be shared and cannot be opened again until the handle to the file or device is closed. For more information, see the Remarks section.

We can use LockFile for instead.

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/enhancementSomething could be better.platform/windowsIssues specific to Windowspriority/P3Low priority, something to be done once everything else is fixed.status/acceptedWe accept to investigate or work on it.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions