Open ettom opened 10 months ago
The reason there are empty files is that a filename needs to be reserved before the committed transaction file can atomically replace it. That prevents another writer getting the same filename which you then replace, deleting the other transaction.
An alternative to creating the "reservation files" is to use the option RENAME_NOREPLACE
of the system call renameat2
. The current strategy can be used in situations where RENAME_NOREPLACE
isn't available.
What do you recommend as a solution for now? Is it safe to delete 0-length files before compacting?
Empty files can be deleted. Empty main
files cannot be deleted because they are what sonnerie uses to identify a database.
@ettom I have committed the change that removes those eprintln
s from the library and into the CLI.
I will leave this ticket open to track that those empty files are created in the first place. That would be an API-breaking change because commit_to
assumes it's allowed to overwrite existing files, but in order to avoid creating empty files, it would be forbidden to do that. However, compactions replace one of the files they compact, either main
or the last transaction file they replaced .
Thanks, sounds great! Would you mind creating a release?
released!
Occasionally, if a writer is cancelled, a 0-length file is left behind. This can be reproduced by running
The timeout will probably need adjusting based on the speed of the filesystem, but on my machine this very quickly produces lots of empty transaction files.
I suppose the behaviour is to be expected and sonnerie can't really prevent this from happening (?), but from an UX perspective, perhaps compacting could also clean up these empty files? Maybe an option flag to do it automatically?