dain / leveldb

Port of LevelDB to Java

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Compaction run goes into a loop.

chirino opened this issue · comments

Once it starts looping, all other read/writes block.

The thread that get stuck looks like this

"leveldb-compaction-0" prio=5 tid=7f8f0dade800 nid=0x115702000 runnable [115701000]
   java.lang.Thread.State: RUNNABLE
    at org.iq80.leveldb.impl.Compaction.isBaseLevelForKey(Compaction.java:163)
    at org.iq80.leveldb.impl.DbImpl.doCompactionWork(DbImpl.java:1004)
    at org.iq80.leveldb.impl.DbImpl.backgroundCompaction(DbImpl.java:444)
    at org.iq80.leveldb.impl.DbImpl.backgroundCall(DbImpl.java:395)
    at org.iq80.leveldb.impl.DbImpl.access$100(DbImpl.java:79)
    at org.iq80.leveldb.impl.DbImpl$2.call(DbImpl.java:370)
    at org.iq80.leveldb.impl.DbImpl$2.call(DbImpl.java:364)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:680)

Added a test case which triggers the bug. See: ApiTest.java

APLO-123 depends on this issue.

The issue is that the line 'levelPointers[level]++;' in Compaction.java (164) should be up inside the while loop in order to eventually get out of that while.