MapDB 2.0 compact() problem

108 views
Skip to first unread message

Michael Charnoky

unread,
Jul 29, 2015, 4:14:22 PM7/29/15
to MapDB
Tried MapDB 2.0-beta3 for the first time today, having used 1.0.x in the past. I'm seeing an exception that happens when I try to perform a Queue.poll() after I do a simple DB.compact(). This used to work in version 1.0.x. Here's the code:

import java.io.File;
import java.util.concurrent.BlockingQueue;
import org.mapdb.DB;
import org.mapdb.DBMaker;

public class MapDBQueue {
    public static void main(String[] args) {
        String filename = System.getProperty("user.home") + "/mapdbtest";
        File file = new File(filename);
        String queueName = "testqueue";
        DB db = DBMaker
            .fileDB(file)
            .fileMmapEnable()
            .transactionDisable()
            .cacheSize(128)
            .closeOnJvmShutdown()
            .make();
        BlockingQueue<String> queue = db.getQueue(queueName);
        String next = queue.poll();
        System.out.println("poll() #1: " +next);
        db.compact();
        next = queue.poll();
        System.out.println("poll() #2: " +next);
    }
}


Result:
Exception in thread "main" org.mapdb.DBException$EngineGetVoid: Recid passed to Engine.get() does not exist. Possible data corruption!
    at org.mapdb.StoreDirect.indexValGet(StoreDirect.java:1293)
    at org.mapdb.StoreDirect.get2(StoreDirect.java:293)
    at org.mapdb.Store.get(Store.java:248)
    at org.mapdb.Engine$CloseOnJVMShutdown.get(Engine.java:453)
    at org.mapdb.Queues$SimpleQueue.poll(Queues.java:103)
    at MapDBQueue.main(MapDBQueue.java:23)

Michael Charnoky

unread,
Jul 31, 2015, 11:04:27 AM7/31/15
to MapDB, no...@noky.net
Whoops, I posted the wrong output. Here's what happens when you run the code for the first time:

poll() #1: null

Michael Charnoky

unread,
Aug 4, 2015, 12:30:34 AM8/4/15
to MapDB, no...@noky.net
Hi Jan, saw you just released beta4, thanks! Tried it out and still getting an exception after the compact(), output is now:

poll() #1: null
Exception in thread "main" org.mapdb.DBException$EngineGetVoid: Recid passed to Engine.get() does not exist. Possible data corruption!
    at org.mapdb.StoreDirect.indexValGet(StoreDirect.java:1429)
    at org.mapdb.StoreDirect.get2(StoreDirect.java:315)
    at org.mapdb.Store.get(Store.java:254)

Dmitriy Shabanov

unread,
Aug 4, 2015, 4:49:08 AM8/4/15
to ma...@googlegroups.com, no...@noky.net
Do you commit before poll after compact? Do you see this after you restart you program?

--
Dmitriy Shabanov

Michael Charnoky

unread,
Aug 4, 2015, 9:18:53 AM8/4/15
to MapDB, no...@noky.net
Hi Dmitry,

Thanks for your feedback. Adding a commit() does not change anything. The error persists when the code is re-run (after the db file is created). The code worked fine for MapDB 1.0.7. I posted a self contained test case previously: https://groups.google.com/forum/#!topic/mapdb/vxZe-J486-Q

Mike
Reply all
Reply to author
Forward
0 new messages