google / google/leveldb

CURRENT file contains duplicated manifest file name

Open
#779 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
39.4k
Forks
8.2k
PR merge metrics
No merged PRs in 30d

Description

Recently we find out there may contain 2 lines of manifest filename in the "CURRENT" file, which results in leveldb open failed with the reason of "No such file or directory".

For example,
root~# cat CURRENT
MANIFEST-096721
MANIFEST-096721

And the leveldb directory may looks like:
----------+ 1 root root 288351 2020-01-21 00:17:04.034207739 +1300 094878.ldb
----------+ 1 root root 0 2020-01-29 18:42:08.631561621 +1300 096722.log
----------+ 1 root root 32 2020-01-29 18:42:12.560608228 +1300 CURRENT
----------+ 1 root root 0 2018-12-06 23:52:01.028274031 +1300 LOCK
----------+ 1 root root 0 2020-02-13 18:43:55.054764937 +1300 LOG
----------+ 1 root root 0 2020-02-13 18:31:52.176408536 +1300 LOG.old
----------+ 1 root root 187 2020-01-29 18:42:08.631561621 +1300 MANIFEST-096721

As you can see the CURRENT file contains two lines with size of 32 bytes, and normally it should be 16 bytes instead. However the manifest file name seems to be correct.

When opening this leveldb, it will compose the wrong path and results in not found error:
"IO error: /root/leveldb/MANIFEST-096721
MANIFEST-096721: No such file or directory"
(The path is splitted into two lines with repeated file name "MANIFEST-096721".)

We are using leveldb in a multi-threaded application, but for each of leveldb, we ensure that there will be only one thread accessing each of leveldb at the same time.

We trace the source code of leveldb, and find out the timing of writing CURRENT file:
A. open leveldb and CURRENT file does not exist.
B. open leveldb and think manifest file should be updated.
C. compaction
D. repair

We ensure A and D will not be the case we encountered, because our application did successfully open and close the leveldb before, and never use the repair funcion. So we wonder if B and C will result in duplicated manifest file name in CURRENT file. For example, power off? abnormal shutdown? or other unknown issue?

Do anyone encounter the same problem, or do anyone knows if it's a known issue?
Thank you!

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.