https://bugs.openldap.org/show_bug.cgi?id=10552
--- Comment #8 from Howard Chu hyc@openldap.org --- (In reply to donxenapo from comment #7)
We have deployed LMDB v1.0.0 from the current tag, and unfortunately looks like the corruption has not stopped.
I recommended you to use the 1.0 release branch. Not the 1.0.0 tag. We're about to release 1.0.1. 1.0.0 is obviously broken.
In version 1.0 Windows uses asynchronous overlapped writes by default. You may want to fall back to using standard synchronous writes instead. Compile LMDB with -DMDB_USE_WRITE_THROUGH=0.
You may want to reconsider NOMETASYNC, it doesn't really gain that much performance.
We added code that recreates the database once a corruption is detected, which lowered our crash rate pretty substantially, but the crashes are still there, mostly with
Error: MDB_PAGE_NOTFOUND: Requested page not found Error: MDB_PROBLEM: Unexpected problem - txn should abort etc
We got a couple user reports that at least some of these crashes happen right after they got a BSOD or a reboot, so looks like there is a higher chance to corrupt the database during an abnormal system shutdown.
One relevant flag we're using here is MDB_NOMETASYNC:
const auto error = mdb_env_open(env.get(), location.c_str(), MDB_NOMETASYNC, 0644);
and from what I understand, LMDB is supposed to handle abnormal shutdowns gracefully with this flag?
We have never reproduced this issue in-house, but in the wild it's in the top 10 of our crashes.