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

Is there a way to know if a compaction failed #28

Open
kavillo opened this issue Dec 12, 2022 · 2 comments
Open

Is there a way to know if a compaction failed #28

kavillo opened this issue Dec 12, 2022 · 2 comments

Comments

@kavillo
Copy link

kavillo commented Dec 12, 2022

Describe the bug
A compaction might fail for different reasons, the most common is that the filesystem is full. In that case the database is not written to the file system. The application keeps running and at the next restart data is partially or fully missing.

To Reproduce
Not sure I could upload a package since we need to make the compacting fails. I just removed the write attribute to a data file to reproduce it.
Expected behavior
I would expect a "compact.fail" event to be called or a status variable that indicates the db is in error.

Actual behavior
"compact.done" event is called with no indication that compacting failed

Logs

Environment info

  • Runtime: Node
  • Version: 12.13.0 and latest stable
  • OS: MacOS, Linux

Additional context
Add any other context about the problem here.

@tex0l
Copy link

tex0l commented Dec 12, 2022

Hi!
The auto compaction feature is set through the setAutocompactionInterval which simply calls a Datastore#compactDatafile, which is the version that is orchestrated through the executor of Persistence#persistCachedDatabaseAsync which only emits a compaction.done when it succeeds, therefore I don't think it emits a compaction.done when it fails, it just silently fails.

We could try/catch it and emit a comapction.failed with the error message in the event I guess.

@kavillo
Copy link
Author

kavillo commented Dec 12, 2022

Thanks for the answer. Yes that would be ideal, in that way we would know if the failure happened even if the compaction is issued by a call to compactDatafileAsync directly.

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