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

Error in makeNewBuffer if DB size exceedes 2GB #313

Closed
JensBee opened this issue Apr 10, 2014 · 4 comments
Closed

Error in makeNewBuffer if DB size exceedes 2GB #313

JensBee opened this issue Apr 10, 2014 · 4 comments
Labels

Comments

@JensBee
Copy link

JensBee commented Apr 10, 2014

The following case fails (tested against trunk), if the database file (npTest.p) grows larger than 2GB (last valid size is always 2147483648). Same result, if .async* options are turned on.
Tested on 64bit linux, so mmap should work.

  @Test
  public void negativePositionTest() throws InterruptedException {
    DB db = DBMaker.newFileDB(new File("npTest"))
            .mmapFileEnableIfSupported()
            .transactionDisable()
            //.asyncWriteEnable()
            //.asyncWriteFlushDelay(100)
            .make();

    Map<String, String> map = db.createTreeMap("data").make();
    for (long i = 0; i < Long.MAX_VALUE; i++) {
      map.put("Entry" + i, " some data " + UUID.randomUUID().toString());
    }
  }

Exception:
java.lang.AssertionError: null at org.mapdb.Volume$MappedFileVol.makeNewBuffer(Volume.java:484) at org.mapdb.Volume$ByteBufferVol.tryAvailable(Volume.java:285) at org.mapdb.Volume.ensureAvailable(Volume.java:49) at org.mapdb.StoreDirect.freePhysTake(StoreDirect.java:1086) at org.mapdb.StoreDirect.longStackPut(StoreDirect.java:972) at org.mapdb.StoreDirect.freePhysPut(StoreDirect.java:1046) at org.mapdb.StoreDirect.longStackTake(StoreDirect.java:946) at org.mapdb.StoreDirect.freePhysTake(StoreDirect.java:1054) at org.mapdb.StoreDirect.longStackPut(StoreDirect.java:972) at org.mapdb.StoreDirect.freePhysPut(StoreDirect.java:1046) at org.mapdb.StoreDirect.update2(StoreDirect.java:525) at org.mapdb.StoreDirect.update(StoreDirect.java:491) at org.mapdb.Caches$HashTable.update(Caches.java:254) at org.mapdb.BTreeMap.put2(BTreeMap.java:747) at org.mapdb.BTreeMap.put(BTreeMap.java:644) at org.mapdb.IssueTest.negativePositionTest(IssueTest.java:38)

@jankotek
Copy link
Owner

Fixed, there was simple integer/long conversion error

@williamleferrand
Copy link

Actually, when the same file now grows to 4Gb, the following exception fires:

Caused by: java.lang.IllegalArgumentException: Negative position
at sun.nio.ch.FileChannelImpl.map(FileChannelImpl.java:822)
at org.mapdb.Volume$MappedFileVol.makeNewBuffer(Volume.java:490)
at org.mapdb.Volume$MappedFileVol.(Volume.java:430)
at org.mapdb.Volume.volumeForFile(Volume.java:176)
at org.mapdb.Volume$1.createPhysVolume(Volume.java:208)
at org.mapdb.StoreDirect.(StoreDirect.java:203)
at org.mapdb.StoreWAL.(StoreWAL.java:57)
at org.mapdb.DBMaker.extendStoreWAL(DBMaker.java:927)
at org.mapdb.DBMaker.makeEngine(DBMaker.java:721)
at org.mapdb.DBMaker.make(DBMaker.java:664)

The size of the .p file is exactly 4GB:

4294967296 Apr 15 14:48 documentcache_mapdb.p

This is done on 64bits linux, running 0.9.12

Should I file another ticket or is it part of that one?

Thanks, & congratulations for the great work!

@jankotek
Copy link
Owner

0.9.13 released with fix

@williamleferrand
Copy link

Wonderful, thanks!

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

No branches or pull requests

3 participants