google / google/leveldb

Data lost after first time restart application.

Open
#736 3 comments 0 reactions 0 assignees View on GitHub
question
Dominant language
C++
Stars
39.4k
Forks
8.2k
PR merge metrics
No merged PRs in 30d

Description

HI all,

I am facing an issue about losing data on the first time restart application with leveldb. My application is using leveldb version 1.20 and running on OpenWRT OS.

I configured to open database as below:
```c++
//database options
m_options.create_if_missing = true;

//open database
m_status = DB::Open(m_options, m_db_location , &p_db);

//write options
m_write_options.sync = true;

//read options
m_read_options.fill_cache = false;
```

The content of database directory at first time:
```
drwxr-xr-x 1 root root 140 Sep 26 10:59
drwxr-xr-x 1 root root 4.0K Sep 26 11:00 ..
-rw-rw-rw- 1 root root 4.5K Sep 26 11:02 000003.log
-rw-rw-rw- 1 root root 16 Sep 26 10:59 CURRENT
-rw-r--r-- 1 root root 0 Sep 26 10:59 LOCK
-rw-rw-rw- 1 root root 53 Sep 26 10:59 LOG
-rw-rw-rw- 1 root root 50 Sep 26 10:59 MANIFEST-000002
```

After the first time restart my application, reboot, or power cycle the machine then the database directory has changed and all my previous data is lost.
```
drwxr-xr-x 1 root root 4.0K Sep 26 11:03 .
drwxr-xr-x 1 root root 4.0K Sep 26 11:00 ..
-rw-rw-rw- 1 root root 4.5K Sep 26 11:03 000005.ldb
-rw-rw-rw- 1 root root 558 Sep 26 11:03 000006.log
-rw-rw-rw- 1 root root 16 Sep 26 11:03 CURRENT
-rw-r--r-- 1 root root 0 Sep 26 10:59 LOCK
-rw-rw-rw- 1 root root 290 Sep 26 11:03 LOG
-rw-rw-rw- 1 root root 53 Sep 26 10:59 LOG.old
-rw-rw-rw- 1 root root 131 Sep 26 11:03 MANIFEST-000004
```

This issue really confuse me because it only happen at the first time and there is no error message from leveldb.

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.