Closed den1k closed 3 months ago
The DB file looks corrupted. We could put in a JVM shutdown hook to close DB, but it won't help if the machine is shutdown or the process is killed unexpectedly. So, 0.9.0 will default to the safe write mode to prevent this from happening. We will also add a JVM shutdown hook in the next release to reduce the chance.
In the meantime I believe you can turn on safe write mode for your application by passing :flags
as [:nordahead :writemap :notls]
(note: this will mean sync flushes to disk, so no concurrent inserts/updates):
(defonce !conn
(d/get-conn "db" schema
{:kv-opts {:flags [:nordahead :writemap :notls]}}))
The default flags are:
The best documentation I have found on these flags is here:
I believe it's :mapasync
that can cause database corruption on crash.
/**
* Use asynchronous msync when {@link #MDB_WRITEMAP} is used.
*
* <p>
* When using {@link #MDB_WRITEMAP}, use asynchronous flushes to disk.
* As with {@link #MDB_NOSYNC}, a system crash can then corrupt the database
* or lose the last transactions. Calling {@link Env#sync(boolean)} ensures
* on-disk database integrity until next commit.
*/
MDB_MAPASYNC(0x10_0000),
Hope that helps.
Restarted the JVM and suddenly can't create a conn