Skip to content

Commit

Permalink
db_stress: db_stress segmentation fault (facebook#9219)
Browse files Browse the repository at this point in the history
Summary:
db_stress asserts/seg-faults with below command (on debug and release builds)

```
"rm -rf /tmp/rocksdbtest*; db_stress --ops_per_thread=1000 --reopen=5"
=======================================
Error opening unique id file for append: IO error: No such file or directory:
While open a file for appending: /tmp/rocksdbtest-0/dbstress/.unique_ids:
No such file or directory
Choosing random keys with no overwrite
Creating 2621440 locks
Starting continuous_verification_thread
2021/11/15-08:46:49  Initializing worker threads
2021/11/15-08:46:49  Starting database operations
2021/11/15-08:46:49  Reopening database for the 1th time
WARNING: prefix_size is non-zero but memtablerep != prefix_hash
DB path: [/tmp/rocksdbtest-0/dbstress]
Segmentation fault
=======================================

```
StressTest() constructor deletes the directory "dbstress" because
the option --destroy_db_initially is true by default in db_stress.

This Seg fault happens on a new database, UniqueIdVerifier's constructor
tries to read the ".unique_ids" file, if the file is not present,
ReopenWritableFile() tries to create .unique_ids file, but fails
as the directory db_stress is not available. The data_file_writer_
is set as an invalid(null) pointer and in subsequent calls (~UniqueIdVerifier()
and UniqueIdVerifier::Verify()) it accesses this null pointer and crashes.

This patch creates db_stress directory if it is missing, so the .unique_ids file
is created.

Signed-off-by: Aravind Ramesh <[email protected]>

Pull Request resolved: facebook#9219

Reviewed By: ajkr

Differential Revision: D32730151

Pulled By: pdillinger

fbshipit-source-id: f47baba56b380d93c3ba5608904756e86bbf14f5
  • Loading branch information
aravind-wdc authored and facebook-github-bot committed Nov 30, 2021
1 parent 7aa31ba commit 9c93281
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions db_stress_tool/db_stress_listener.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@ UniqueIdVerifier::UniqueIdVerifier(const std::string& db_name)
FileSystem& fs = *FileSystem::Default();
IOOptions opts;

Status st = fs.CreateDirIfMissing(db_name, opts, nullptr);
if (!st.ok()) {
fprintf(stderr, "Failed to create directory %s: %s\n",
db_name.c_str(), st.ToString().c_str());
exit(1);
}

{
std::unique_ptr<FSSequentialFile> reader;
Status s =
Expand Down

0 comments on commit 9c93281

Please sign in to comment.