jankotek / jankotek/mapdb

NullPointerException with in memory BTreeMap on concurrent writes

Open
#910 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

3.0 bug
Dominant language
Java
Stars
5.1k
Forks
877
PR merge metrics
No merged PRs in 30d

Description

With a code structure like:

try (DB db = DBMaker.memoryDB().make()) {
      BTreeMap<Long, Integer> tempRevisionTopicOutput = db.treeMap("test").keySerializer(Serializer.LONG).valueSerializer(Serializer.INTEGER).createOrOpen();
     stream..parallel().forEach(data -> {
         //Some computation
         test.put(a, b);
     });
}

I get the following exception:

GRAVE: null
java.lang.NullPointerException
        at org.mapdb.volume.ByteArrayVol.getSlice(ByteArrayVol.java:65)
        at org.mapdb.volume.ByteArrayVol.getLong(ByteArrayVol.java:237)
        at org.mapdb.StoreDirect.getIndexVal(StoreDirect.kt:128)
        at org.mapdb.StoreDirect.updateProtected(StoreDirect.kt:642)
        at org.mapdb.StoreDirect.update(StoreDirect.kt:634)
        at org.mapdb.BTreeMap.put2(BTreeMap.kt:408)
        at org.mapdb.BTreeMap.put(BTreeMap.kt:292)

Environment:

openjdk version "1.8.0_171"
OpenJDK Runtime Environment (build 1.8.0_171-8u171-b11-0ubuntu0.16.04.1-b11)
OpenJDK 64-Bit Server VM (build 25.171-b11, mixed mode)

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the parallel-write example and follow the stack through BTreeMap.kt, StoreDirect.kt, and ByteArrayVol.java, beginning at ByteArrayVol.getSlice. Done means concurrent writes to the in-memory BTreeMap no longer produce the reported NullPointerException.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.