Full_Name: Hallvard B Furuseth Version: lmdb 0.9.14 OS: URL: Submission from: (NULL) (81.191.45.22) Submitted by: hallvard mdb_env_sync() works with MDB_RDONLY at least on Unix, but it syncs MDB_WRITEMAP changes incorrectly: fdatasync instead of msync because mdb_env_open() cleared MDB_WRITEMAP. Users are likely doing the same thing anyway: Using MDB_RDONLY instead of MDB_RDONLY|MDB_WRITEMAP on WRITEMAP-written DBs. Finally, writers committing with and without WRITEMAP will sync each others' commits incorrectly. lmdb.h does warn they will "not cooperate well", but it should warn it breaks ACID. LMDBv2 can instead fix all this with 2 bits in MDB_meta: "Changed with/without WRITEMAP since last sync". In LMDBv1, I think the smallest-impact fix is for env_sync to both msync and fdatasync when RDONLY is set and WRITEMAP is clear. A greedier fix would be to always sync both ways when the user calls env_sync. Either way, it may be best to keep WRITEMAP when RDONLY. Only env_map() needs to deal with that. Pushing suggestions except doc to "mdb/wmap-fix" in my repo.
h.b.furuseth@usit.uio.no wrote: > Full_Name: Hallvard B Furuseth > Version: lmdb 0.9.14 > OS: > URL: > Submission from: (NULL) (81.191.45.22) > Submitted by: hallvard > > > mdb_env_sync() works with MDB_RDONLY at least on Unix, but > it syncs MDB_WRITEMAP changes incorrectly: fdatasync instead > of msync because mdb_env_open() cleared MDB_WRITEMAP. > > Users are likely doing the same thing anyway: Using MDB_RDONLY > instead of MDB_RDONLY|MDB_WRITEMAP on WRITEMAP-written DBs. mdb_env_sync() shouldn't even be doing any work at all if the env was opened RDONLY. We should return nop in that case. RDONLY means RDONLY! No writes, no calls that will alter the storage layer. -- -- Howard Chu CTO, Symas Corp. http://www.symas.com Director, Highland Sun http://highlandsun.com/hyc/ Chief Architect, OpenLDAP http://www.openldap.org/project/
On 08/01/15 20:59, Howard Chu wrote: > mdb_env_sync() shouldn't even be doing any work at all if the env was > opened RDONLY. We should return nop in that case. RDONLY means RDONLY! Currently it syncs changes written by another process.
On 08/01/15 20:52, h.b.furuseth@usit.uio.no wrote: > Users are likely doing the same thing anyway: Using MDB_RDONLY > instead of MDB_RDONLY|MDB_WRITEMAP on WRITEMAP-written DBs. Er, I mean if any users are doing this. But users do come up with things that the developers never thought of.
changed notes changed state Open to Test moved from Incoming to Software Bugs
partial fix in master. Revisit for LMDBv2.
changed notes
changed state Test to Closed
changed state Closed to Partial