Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lock file does not prevent opening two databases from the same process #3292

Open
mewim opened this issue Apr 16, 2024 · 0 comments
Open

Lock file does not prevent opening two databases from the same process #3292

mewim opened this issue Apr 16, 2024 · 0 comments

Comments

@mewim
Copy link
Collaborator

mewim commented Apr 16, 2024

For example:

db_path = tmp_path / "test_database_close.kuzu"
db1 = kuzu.Database(database_path = db_path, read_only = False)
assert not db1.is_closed
assert db1._database is not None

db2 = kuzu.Database(database_path = db_path, read_only = False)
assert not db2.is_closed
assert db2._database is not None

this does not throw any error and created two instances of read-write databases in the same Python process. This is likely due to that only one F_WRLCK lock is held per process:

A single process can hold only one type of lock on a file region; if a new lock is applied to an already-locked region, then the existing lock is converted to the new lock type. (Such conversions may involve splitting, shrinking, or coalescing with an existing lock if the byte range specified by the new lock does not precisely coincide with the range of the existing lock.)

Such behavior may not be desirable. We should decide whether we need to do additional work to prevent this and make this behavior clear to the user in our docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant