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

Destroying a DbInstance #202

Open
aramallo opened this issue Nov 23, 2023 · 2 comments
Open

Destroying a DbInstance #202

aramallo opened this issue Nov 23, 2023 · 2 comments

Comments

@aramallo
Copy link

Hi,

I am building an Erlang binding using the Rust library.

At the moment I am creating an instance using DbInstance::new to open a database, but there is no function to close the instance. How can I close a database?

@aramallo
Copy link
Author

aramallo commented Nov 29, 2023

So far I managed to use the same technique you are using on the C bindings. That is, I create a struct to keep track of the handles created with DBInstance.new and allow the user to call close(id) which removes the handle and thus Rust destroys the instance. The issue still is that engines like RocksDB will take some time to tear down which might lead to a race condition when immediately tryin to re-open the same database (as the rocksdb files are locked).

So it would be nice to have a close function that waits for RocksDB termination.

@Madd0g
Copy link

Madd0g commented Nov 29, 2023

so that's what's been happening to me!

I have a development server that is restarts on any change to the code and it has worked beautifully for me for a while now, no lock errors.

But then I wrote some tests, and the tester in watch mode destroys and then creates the DB in quick succession and often it blows up on not being able to achieve a lock on the file.

It would be great if it was a promise that resolves after everything is actually closed.

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

2 participants