https://bugs.openldap.org/show_bug.cgi?id=9291
--- Comment #18 from Howard Chu hyc@openldap.org --- (In reply to Markus from comment #16)
(In reply to Howard Chu from comment #15)
Use mm_last_pg from the meta page.
Actually, that's already been checked for you, you only need to compare to mt_next_pgno. And mdb_page_get already checks it. Though perhaps the check could be done earlier in that function.
Right, checking this earlier seems a good idea as the check might be skipped otherwise by one of the gotos?
- What kept me away from using mm_last_pg was its comment "Actually the
file may be shorter if the freeDB lists the final pages." So I wasn't sure if and when there are cases when mm_last_pg points beyond the file(?).
It's possible for some pages to be dirtied at the end of the file, but then get deleted/unused again before the txn commits. If nothing else in the txn tries to reuse them, they'll go onto the freeDB. If this happens, then technically we've allocated those pages, but since they never got flushed to the filesystem, the file may be shorter.
- mt_next_pgno itself should be checked against the file size on opening. I
think, I'll update the submitted patch.