fix locking around cache preallocation
Caveats in LMDB docs suggest that our cache preallocation might break LMDB locking:
Do not have open an LMDB database twice in the same process at the same time. Not even from a plain open() call - close()ing it breaks flock() advisory locking.