https://bugs.openldap.org/show_bug.cgi?id=9397
--- Comment #6 from github@nicwatson.org github@nicwatson.org --- (In reply to Howard Chu from comment #5)
(In reply to github@nicwatson.org from comment #4)
(In reply to Howard Chu from comment #3)
2nd: We can simply skip ftruncate on any requests to shrink the map. There is no pressing reason to perform the operation. Since we don't use fallocate, the excess size isn't actually consuming any disk space yet, so ftruncate doesn't save any disk space.
I was planning on passing the "excl" value from mdb_env_open2 to a new parameter to mdb_env_map, and only allow the filesize to decrease when excl is True (and the running process has an exclusive lock). This would preserve the existing behavior with a single process user.
This still ignores the fact that there is never any actual need to shrink the filesize.
HFS+ filesystems on MacOS do not support sparse files. ftruncate allocates (and deallocates) real disk space on these platforms.