dain / leveldb

Port of LevelDB to Java
Apache License 2.0
1.54k stars 429 forks source link

Cannot open table, No such file XYZ.sst #73

Open wolfposd opened 8 years ago

wolfposd commented 8 years ago

Not sure if Bug or different LevelDB version. But in my DB there are no ...sst files only ...ldb files, so i get the following error:

java.lang.RuntimeException: Could not open table 3 at org.iq80.leveldb.impl.TableCache.getTable(TableCache.java:97) at org.iq80.leveldb.impl.TableCache.newIterator(TableCache.java:78) at org.iq80.leveldb.impl.TableCache.newIterator(TableCache.java:73) at org.iq80.leveldb.impl.Version.getLevel0Files(Version.java:146) at org.iq80.leveldb.impl.DbImpl.internalIterator(DbImpl.java:776) at org.iq80.leveldb.impl.DbImpl.iterator(DbImpl.java:742) at org.iq80.leveldb.impl.DbImpl.iterator(DbImpl.java:733) at org.iq80.leveldb.impl.DbImpl.iterator(DbImpl.java:1) at java.lang.Iterable.forEach(Iterable.java:74) at com.github.wolfposd.StartupLevelDB.main(StartupLevelDB.java:30) Caused by: java.io.FileNotFoundException: mydatabase.db/000003.sst (No such file or directory) at java.io.FileInputStream.open0(Native Method) at java.io.FileInputStream.open(FileInputStream.java:195) at java.io.FileInputStream.(FileInputStream.java:138) at org.iq80.leveldb.impl.TableCache$TableAndFile.(TableCache.java:122) at org.iq80.leveldb.impl.TableCache$TableAndFile.(TableCache.java:117) at org.iq80.leveldb.impl.TableCache$2.load(TableCache.java:66) at org.iq80.leveldb.impl.TableCache$2.load(TableCache.java:1) at com.google.common.cache.LocalCache$LoadingValueReference.loadFuture(LocalCache.java:3527) at com.google.common.cache.LocalCache$Segment.loadSync(LocalCache.java:2319) at com.google.common.cache.LocalCache$Segment.lockedGetOrLoad(LocalCache.java:2282) at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2197) at com.google.common.cache.LocalCache.get(LocalCache.java:3937) at com.google.common.cache.LocalCache.getOrLoad(LocalCache.java:3941) at com.google.common.cache.LocalCache$LocalLoadingCache.get(LocalCache.java:4824) at org.iq80.leveldb.impl.TableCache.getTable(TableCache.java:90) ... 9 more

However, when i change org.iq80.leveldb.impl.Filename.java#59 from "sst" to "ldb" it works fine

AlanVerbner commented 7 years ago

Hi @wolfposd. I think your issue is due a different leveldb version. Current repository version only supports sst files but this was changed in https://github.com/google/leveldb/commit/0b9a89f40efdd143fa1426e7d5cd997f67ba6361 (Release LevelDB 1.14 release). I think it was due an extension conflict in Windows. You can find more info here.

dzwiener commented 7 years ago

Use: https://github.com/fusesource/leveldbjni

nicman42 commented 7 years ago

Same problem with org.fusesource.leveldbjni with windows 10. I tried Version 1.8, 1.8-redhat.003, 1.13-redhat.002. I only need Readonly-Access to the leveldb, so my workaround is, copying all files and rename .ldb to .sst

dzwiener commented 7 years ago

Exact same error? I was able to read my .ldb files when using that library.

nicman42 commented 7 years ago

Not exactly the same error but: org.fusesource.leveldbjni.internal.NativeDB$DBException: Corruption: 7 missing files; e.g.: C:\Users\zimmermann\AppData\Local\Temp\leveldb7307729845232549361/000005.sst at org.fusesource.leveldbjni.internal.NativeDB.checkStatus(NativeDB.java:200) ~[leveldbjni-all-1.8.jar:1.8] at org.fusesource.leveldbjni.internal.NativeDB.open(NativeDB.java:218) ~[leveldbjni-all-1.8.jar:1.8] at org.fusesource.leveldbjni.JniDBFactory.open(JniDBFactory.java:168) ~[leveldbjni-all-1.8.jar:1.8] at com.zimmerbell.repaper.sources.MomentumSource.updateFromLevelDB(MomentumSource.java:85) ~[classes/:?] at com.zimmerbell.repaper.sources.MomentumSource.update(MomentumSource.java:69) ~[classes/:?] at com.zimmerbell.repaper.Repaper.update(Repaper.java:243) [classes/:?] at com.zimmerbell.repaper.Repaper.<init>(Repaper.java:96) [classes/:?] at com.zimmerbell.repaper.Repaper.main(Repaper.java:84) [classes/:?]

dzwiener commented 7 years ago

It sounds like you were renaming files when you were making a hack. Perhaps if you redownload the DB it will resolve the issue? If not, could you post your brief code grabbing an itr?

nicman42 commented 7 years ago

I quickly wrote a test that opens the leveldb of (a copy of) your chrome profile: https://github.com/noooz/repaper/blob/master/src/test/java/com/zimmerbell/repaper/ReadLevelDBTest.java It fails, if you remove the renaming in line 26.

quwenzhe commented 4 years ago

I have the same problem @dain Can you help us?