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.87k stars 872 forks source link

recid is not returned to RECID_LONG_STACK after preallocate+delete #985

Open javier-godoy opened 3 years ago

javier-godoy commented 3 years ago

MapDb 3.0.8. StoreWAL and StoreDirect do not releaseRecid if oldSize == NULL_RECORD_SIZE, thus preallocating and deleting a recid (without ever writing a value to it) will cause the recid not to be reused.

Compare:

long r1 = store.preallocate();
store.update(r1, 1, Serializer.INTEGER);
store.delete(r1, Serializer.INTEGER);
long r2 = store.preallocate();

with:

long r1 = store.preallocate();
store.delete(r1, Serializer.INTEGER);
long r2 = store.preallocate();

In the first case r1==r2, but the second one results in r1!=r2