jankotek / mapdb

MapDB provides concurrent Maps, Sets and Queues backed by disk storage or off-heap-memory. It is a fast and easy to use embedded Java database engine.
https://mapdb.org
Apache License 2.0
4.89k stars 873 forks source link

Cleaner hack does not release buffer for readonly mapdb files #1016

Open MGathier opened 1 year ago

MGathier commented 1 year ago

When a DB is opened with fileMmapEnabled and cleanerHackEnabled in readonly mode, closing the database does not clean the buffer. The following message is logged: Apr 25, 2023 11:34:16 AM org.mapdb.volume.ByteBufferVol unmap WARNING: Failed to free the buffer. java.io.IOException: java.lang.IllegalArgumentException: duplicate or slice

This is caused by the fact that buffer in MappedFileVolSingle is set to a duplicate of the original buffer when it is readonly. The close tries to unmap the duplicate of the buffer, not the original buffer.

This occurs in version 3.0.9.