Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Found setting where I lose part of a List value 'silently' #102

Open
reuschling opened this issue Jan 31, 2013 · 1 comment
Open

Found setting where I lose part of a List value 'silently' #102

reuschling opened this issue Jan 31, 2013 · 1 comment

Comments

@reuschling
Copy link

I store LinkedList values with String keys and sadly, more or less by accident, I recognized that jdbm loses a single entry from a LinkedList that I stored. I tried to reproduce this in a small snippet which was not so easy, because most of the times everything worked well - but now I have a stable setting (see below). The snippet runs on a linux 64 bit jdk 1.7.0_09-b05. I started with the jdbm3-alpha4, tried 5, and now I use the current snapshot. No difference.
I guess it could be something with the serialization, because the behaviour is only seen after writing a certain amount of entries. Here is the according snippet:

    DB jdbmDB = DBMaker.openFile("testDB").disableTransactions().disableLocking().deleteFilesAfterClose().closeOnExit().make();
    Map<String, LinkedList<String>> map = jdbmDB.createTreeMap("testMap");

    int iLoops = 2000000;
    for (int i = 0; i < iLoops; i++)
    {
        String strRandomKey = String.valueOf(Math.random());
        LinkedList<String> llVals4RandomKey = map.get(strRandomKey);
        if(llVals4RandomKey == null)
        {
            llVals4RandomKey = new LinkedList<String>();
            map.put(strRandomKey, llVals4RandomKey);
        }
        llVals4RandomKey.add(UUID.randomUUID().toString());


        if(i == (int) (iLoops * 0.9))
        {
            System.out.println("insert first");
            LinkedList<String> llFirstValue = new LinkedList<String>();
            map.put("ourKey", llFirstValue);
            llFirstValue.add("firstValue");
        }
        if(i == (int) (iLoops * 0.97))
        {
            System.out.println("insert second");
            LinkedList<String> llValues = map.get("ourKey");
            llValues.add("secondValue");
        }


        if(i % 100000 == 0) System.out.println(i);
    }


    System.out.println(map.get("ourKey"));
    if(map.get("ourKey").size() < 2)
        System.err.println("second value is lost :(");
    else
        System.out.println("everything seems to be fine...");

    jdbmDB.close();
@jankotek
Copy link
Owner

JDBM3 is no longer supported. Please migrate to MapDB (aka JDBM4)

On Thursday 31 January 2013 09:52:39 reuschling wrote:

I store LinkedList values with String keys and sadly, more or less by
accident, I recognized that jdbm loses a single entry from a LinkedList that I
stored. I tried to reproduce this in a small snippet which was not so easy,
because most of the times everything worked well - but now I have a stable
setting (see below). The snippet runs on a linux 64 bit jdk 1.7.0_09-b05. I
started with the jdbm3-alpha4, tried 5, and now I use the current snapshot. No
difference.
I guess it could be something with the serialization, because the behaviour is
only seen after writing a certain amount of entries. Here is the according
snippet:
DB jdbmDB = DBMaker.openFile("testDB").disableTransactions().disableLocking().deleteFilesAfterClose().closeOnExit().make();
Map<String, LinkedList> map = jdbmDB.createTreeMap("testMap");

int iLoops = 1500000;
for (int i = 0; i < iLoops; i++)
{
    String strRandomKey = String.valueOf(Math.random());
    LinkedList<String> llVals4RandomKey = map.get(strRandomKey);
    if(llVals4RandomKey == null)
    {
        llVals4RandomKey = new LinkedList<String>();
        map.put(strRandomKey, llVals4RandomKey);
    }
    llVals4RandomKey.add(UUID.randomUUID().toString());


    if(i == (int) (iLoops * 0.9))
    {
        System.out.println("insert first");
        LinkedList<String> llFirstValue = new LinkedList<String>();
        map.put("ourKey", llFirstValue);
        llFirstValue.add("firstValue");
    }
    if(i == (int) (iLoops * 0.97))
    {
        System.out.println("insert second");
        LinkedList<String> llValues = map.get("ourKey");
        llValues.add("secondValue");
    }


    if(i % 100000 == 0) System.out.println(i);
}


System.out.println(map.get("ourKey"));
if(map.get("ourKey").size() < 2)
    System.err.println("second value is lost :(");
else
    System.out.println("everything seems to be fine...");

jdbmDB.close();


Reply to this email directly or view it on GitHub.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants