lucaong / cubdb

Elixir embedded key/value database
Apache License 2.0
556 stars 23 forks source link

Bugfix/lost file descriptors #33

Closed meyercm closed 3 years ago

meyercm commented 3 years ago

Creating this PR to make comparisons easy - this isn't quite ready for merging though, as the second test I added is experiencing some noise from the other tests. I'm going to be away from my machine for the rest of the day though, and didn't want to hold you up.

The changes are using :gproc to keep track of all the files that are currently open inside of Store.File, and then closing them before removing or renaming them. Interestingly, the ensure_exclusive_access/1 function was flummoxed by the rename issue, because the _.compact file was checked when opened, but not checked again when renamed.

If you've never used :gproc before, its a really solid process registry, and has a really good pedigree.

lucaong commented 3 years ago

Thanks a lot for your PR! I will close it, as the issue is fixed by https://github.com/lucaong/cubdb/pull/34 with a similar approach, which we both reviewed.