pcmind / leveldb

Port of LevelDB to Java
Apache License 2.0
24 stars 9 forks source link

Data compatibility about LevelDB-0.11 (backward compatible) #4

Closed MIMIEYES closed 5 years ago

MIMIEYES commented 5 years ago

First of all, I admire you for starting to maintain the Java version of LevelDB.

I have encountered some problems during use. I generated some data in the version 0.10 leveldb, copied the data files to the version 0.11 leveldb environment for a while, it was successful, and regenerated some data, then copied the database file to version 0.10. When running in the leveldb environment, an exception will occur. Could you tell me what happened?

2018-12-04 17:41:20.566 [Process-consensus] ERROR - io.nuls.db.manager.LevelDBManager.entryList(LevelDBManager.java:768):
java.lang.RuntimeException: Could not open table 46
    at org.iq80.leveldb.impl.TableCache.getTable(TableCache.java:98) ~[leveldb-0.10.jar:0.10]
    at org.iq80.leveldb.impl.TableCache.newIterator(TableCache.java:79) ~[leveldb-0.10.jar:0.10]
    at org.iq80.leveldb.impl.TableCache.newIterator(TableCache.java:74) ~[leveldb-0.10.jar:0.10]
    at org.iq80.leveldb.impl.Version.getLevel0Files(Version.java:147) ~[leveldb-0.10.jar:0.10]
    at org.iq80.leveldb.impl.DbImpl.internalIterator(DbImpl.java:778) ~[leveldb-0.10.jar:0.10]
    at org.iq80.leveldb.impl.DbImpl.iterator(DbImpl.java:744) ~[leveldb-0.10.jar:0.10]
    at org.iq80.leveldb.impl.DbImpl.iterator(DbImpl.java:735) ~[leveldb-0.10.jar:0.10]
    at org.iq80.leveldb.impl.DbImpl.iterator(DbImpl.java:84) ~[leveldb-0.10.jar:0.10]
    at io.nuls.db.manager.LevelDBManager.entryList(LevelDBManager.java:748) ~[db-leveldb-1.1.5.jar:na]
    at io.nuls.db.service.impl.LevelDBServiceImpl.entryList(LevelDBServiceImpl.java:123) [db-leveldb-1.1.5.jar:na]
    at io.nuls.consensus.poc.storage.service.impl.DepositStorageServiceImpl.getList(DepositStorageServiceImpl.java:119) [consensus-poc-storage-1.1.5.jar:na]
    at io.nuls.consensus.poc.cache.CacheLoader.loadDepositList(CacheLoader.java:158) [consensus-poc-base-1.1.5.jar:na]
    at io.nuls.consensus.poc.manager.CacheManager.load(CacheManager.java:74) [consensus-poc-base-1.1.5.jar:na]
    at io.nuls.consensus.poc.scheduler.ConsensusScheduler.initDatas(ConsensusScheduler.java:181) [consensus-poc-base-1.1.5.jar:na]
    at io.nuls.consensus.poc.scheduler.ConsensusScheduler.start(ConsensusScheduler.java:88) [consensus-poc-base-1.1.5.jar:na]
    at io.nuls.consensus.poc.module.impl.PocConsensusModuleBootstrap.start(PocConsensusModuleBootstrap.java:68) [consensus-poc-base-1.1.5.jar:na]
    at io.nuls.kernel.module.thread.ModuleRunner.run(ModuleRunner.java:56) [kernel-1.1.5.jar:na]
    at java.lang.Thread.run(Thread.java:748) [na:1.8.0_131]
    at io.nuls.kernel.thread.BaseThread.run(BaseThread.java:85) [kernel-1.1.5.jar:na]
Caused by: java.io.FileNotFoundException: C:\NULS\data\consensus_deposit\leveldb\000046.sst (系统找不到指定的文件。)
    at java.io.FileInputStream.open0(Native Method) ~[na:1.8.0_131]
    at java.io.FileInputStream.open(FileInputStream.java:195) ~[na:1.8.0_131]
    at java.io.FileInputStream.<init>(FileInputStream.java:138) ~[na:1.8.0_131]
    at org.iq80.leveldb.impl.TableCache$TableAndFile.<init>(TableCache.java:123) ~[leveldb-0.10.jar:0.10]
    at org.iq80.leveldb.impl.TableCache$TableAndFile.<init>(TableCache.java:114) ~[leveldb-0.10.jar:0.10]
    at org.iq80.leveldb.impl.TableCache$1.load(TableCache.java:67) ~[leveldb-0.10.jar:0.10]
    at org.iq80.leveldb.impl.TableCache$1.load(TableCache.java:62) ~[leveldb-0.10.jar:0.10]
    at com.google.common.cache.LocalCache$LoadingValueReference.loadFuture(LocalCache.java:3628) ~[guava-20.0.jar:na]
    at com.google.common.cache.LocalCache$Segment.loadSync(LocalCache.java:2336) ~[guava-20.0.jar:na]
    at com.google.common.cache.LocalCache$Segment.lockedGetOrLoad(LocalCache.java:2295) ~[guava-20.0.jar:na]
    at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2208) ~[guava-20.0.jar:na]
    at com.google.common.cache.LocalCache.get(LocalCache.java:4053) ~[guava-20.0.jar:na]
    at com.google.common.cache.LocalCache.getOrLoad(LocalCache.java:4057) ~[guava-20.0.jar:na]
    at com.google.common.cache.LocalCache$LocalLoadingCache.get(LocalCache.java:4986) ~[guava-20.0.jar:na]
    at org.iq80.leveldb.impl.TableCache.getTable(TableCache.java:91) ~[leveldb-0.10.jar:0.10]
    ... 18 common frames omitted
pcmind commented 5 years ago

This is a "forward" compatibility issue :). You are using a 0.11 DB with a 0.10 codebase. This is not supported. Anyway, Leveldb 0.11 use a different file extension (.ldb) instead of the old .sst. When you opened the DB with 0.11 codebase, some new .ldb files where created. When you tried to open it back with 0.10, those new table file had an unexpected extension.

At your own risk, you may try to replace all .ldb file extension to the old .sst one.

MIMIEYES commented 5 years ago

Thank you for your reply. By the way, why change the file extension?

pcmind commented 5 years ago

To be compatible with newer Google Leveldb versions. They also did this change.

MIMIEYES commented 5 years ago

Thank you very much.