I am having a hard time understanding how exactly mdb_env_sync should be used. Suppose I have an environment with MDB_NOSYNC and I do not use MDB_WRITEMAP. I still want to sync at some points, which is why mdb_env_sync exists. But I wonder:
- How does it interact with transactions? Is it safe (or necessary) to call it outside of a transaction? During a read-only transaction? During a write transaction?
- What about thread safety? Can it be called concurrently with writes? Can it be called concurrently with another mdb_env_sync in another thread?
mdb_env_sync simply calls fsync (or equivalent) on the database file. It does not interact with transactions, and can be called concurrently with itself. When it returns, transactions completed before mdb_env_sync was started are persisted on the filesystem.
Pierre Chapuis wrote:
I am having a hard time understanding how exactly mdb_env_sync should be used. Suppose I have an environment with MDB_NOSYNC and I do not use MDB_WRITEMAP. I still want to sync at some points, which is why mdb_env_sync exists. But I wonder:
- How does it interact with transactions? Is it safe (or necessary) to call it outside of a transaction? During a read-only transaction? During a write transaction?
Since mdb_env_sync() doesn't take a txn as a parameter, it is impossible to call it inside of a transaction.
- What about thread safety? Can it be called concurrently with writes? Can it be called concurrently with another mdb_env_sync in another thread?
Try it and see.
openldap-technical@openldap.org