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 for single process restriction #98

Open
ethe opened this issue Aug 20, 2024 · 7 comments
Open

Lock for single process restriction #98

ethe opened this issue Aug 20, 2024 · 7 comments
Assignees
Labels
bug Something isn't working good first issue Good for newcomers S - Small Fixing small bugs, adjusting UI styles, optimizing existing functions.

Comments

@ethe
Copy link
Member

ethe commented Aug 20, 2024

Currently, Tonbo only supports single-process read and write operations. Accessing the database file from multiple processes can lead to undefined behavior. However, Tonbo does not prevent this. Therefore, Tonbo should implement a mechanism to lock access to the database files.

@ethe ethe added bug Something isn't working good first issue Good for newcomers labels Aug 20, 2024
@irenjj
Copy link

irenjj commented Aug 21, 2024

I'd like to take it :)

@KKould KKould added the S - Small Fixing small bugs, adjusting UI styles, optimizing existing functions. label Sep 3, 2024
@PhVHoang
Copy link

PhVHoang commented Oct 2, 2024

Hi @ethe , a silly question as I'm new to the project as well.

Should this locking mechanism be implemented in https://github.com/tonbo-io/fusio ? And will the lock prevent both read & write operations from multiple processes? Or only writes will be locked?

@ethe
Copy link
Member Author

ethe commented Oct 2, 2024

Hi @PhVHoang , I think it is different level behavior. Linux file system allows access a single file across multiple process, fusio does not promise much more safety than OS (or any other storage backend). locking db file (folder) to prevent logical error is the Tonbo requirement. Therefore, I think it might be better to lock folder on Tonbo (or other application) level.

@ethe ethe changed the title Lock for single process restriction Lock for single processor restriction Oct 2, 2024
@ethe ethe changed the title Lock for single processor restriction Lock for single process restriction Oct 2, 2024
@KKould
Copy link
Collaborator

KKould commented Oct 9, 2024

The locks between multiple processes are often fslock, which should depend on the underlying implementation of each system such as libc::flock, so I think this issue depends on fusio.

@ethe
Copy link
Member Author

ethe commented Oct 9, 2024

Sure, fusio promises operation atomicity on local fs (fusio just pass through operations to local fs), however, the "lock" logic of Tonbo should be implmented in Tonbo, what Tonbo needs is db instance lock cross multiple files (wal log, version log, parquet files, etc.)

I was misunderstanding, I get it now, considering the target of fusio, I think fusio might not provide a lock abstraction, because fs lock does not make sense to other fs implementation than local fs. Just use std fs lock (or libc) should be fine.

@KKould
Copy link
Collaborator

KKould commented Oct 9, 2024

It is a question whether OPFS supports fslock as planned under WASM (even if tonbo forces base_fs to be local, does all local storage support fslock ?)

@ethe
Copy link
Member Author

ethe commented Oct 9, 2024

does all local storage support fslock ?

It depends on target OS, I think in the most of cases it is guaranteed, OPFS does not support parallel read write on default.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers S - Small Fixing small bugs, adjusting UI styles, optimizing existing functions.
Projects
None yet
Development

No branches or pull requests

4 participants