Details
-
Bug
-
Resolution: Fixed
-
Major
-
2.5.0
-
Security Level: Public
-
None
-
May also affect earlier versions I observed this issue while reading couchstore codebase.
-
Untriaged
-
KV: Feb 2 - Feb 15
Description
I discussed this with Aaron in irc and he agreed there may be a problem.
The code here:
https://github.com/couchbase/couchstore/blob/master/src/couch_db.cc#L189-L193
is attempting to extend the file size to account for the header which will subsequently be written after the first fsync. (this allows the second fsync to be an fdatasync, which avoids writing metadata)
But, the headers need to be aligned on 4096-byte block boundaries and this calculation does not account for that. Further the db_write_buf() method does not account for that either.
This means that in most cases, the file size will change again when we actually write header.