yahoo / HaloDB

A fast, log structured key-value store.
https://yahoodevelopers.tumblr.com/post/178250134648/introducing-halodb-a-fast-embedded-key-value
Apache License 2.0
506 stars 99 forks source link

Got FileSystemException when repairing database #23

Open tworogue opened 5 years ago

tworogue commented 5 years ago

Every time when repairing database after incorrect shutdown I get following error:

Caused by: java.nio.file.FileSystemException: C:\database\1549869944.index.repair -> C:\database\1549869944.index: The process cannot access the file because it is being used by another process.

It seems like when calling method openDataFilesForReading() my '.index' file has been opened for reading and hadn't been closed after it. No other processes use this file.

So when we call method repairFile(DBDirectory dbDirectory) we get an exception in line: Files.move(repairFile.indexFile.getPath(), indexFile.getPath(), REPLACE_EXISTING, ATOMIC_MOVE);

Any suggestions on how to avoid this error?

wangtao724 commented 4 years ago

Are you still experiencing the issue on latest version?

RisbergAdam commented 3 years ago

I am still experiencing this issue. The exception is thrown from this line in HaloDBFile. Both me and @tworogue are on Windows, that might be why? The documentation for Files.move states this for the ATOMIC_MOVE flag:

The move is performed as an atomic file system operation and all other options are ignored. If the target file exists then it is implementation specific if the existing file is replaced or this method fails by throwing an IOException.

Edit: I removed the ATMIC_MOVE flag but that did not solve anything.