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

Importance of db.Close() #375

Open
rendaw opened this issue Oct 4, 2021 · 1 comment
Open

Importance of db.Close() #375

rendaw opened this issue Oct 4, 2021 · 1 comment

Comments

@rendaw
Copy link

rendaw commented Oct 4, 2021

Is db.Close() optional? My main concern is if panic could lead to a corrupt database.

@LuciferMS
Copy link

I think is better to call db.Close function to close db. Because it is better to release the resource which is leveldb using, such as filelock, writer and reader of database file.I know what you're worried about.Don't worry, calling the close method will not cause problems with the database. The data in memory will be written to disk by WAL logging, and if you call the OpenDB method again with the same path, the data in memory will be restored to memory by reading the log.

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