facebook / facebook/rocksdb

Segfault in BG Compaction

Open
#5,418 8 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
32.1k
Forks
6.9k
Avg merge
32m
Merged PRs (30d)
1

Description

I frequently see a SIGSEGV in the BG thread performing compaction. This is in version 6.2.0 (just pulled latest code 6/4/2019).

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7feb863a5700 (LWP 3638)]
0x00007ffff4ce3b59 in std::string::assign(std::string const&) ()
from /lib64/libstdc++.so.6
(gdb) up
#1 0x00007ffff734d465 in operator= (__str=..., this=0x7feb863a1b90)
at /usr/include/c++/4.9.2/bits/basic_string.h:555
555 { return this->assign(__str); }

The problem is that compaction is using input[0] when the input array has no elements (its empty), thus triggering an exception.

#3 rocksdb::CompactionPicker::GetRange (this=0x7feb04015f40, inputs=...,
smallest=smallest@entry=0x7feb863a1b40, largest=largest@entry=0x7feb863a1b90)
at db/compaction/compaction_picker.cc:175
175 *largest = inputs[inputs.size() - 1]->largest;
(gdb) l
170 }
171 }
172 }
173 } else {
174 *smallest = inputs[0]->smallest; // dnevil - need to make sure input[] is not empty
175 *largest = inputs[inputs.size() - 1]->largest;
176 }
177 }

Here is the backtrace.

(gdb) bt
#0 0x00007ffff4ce3b59 in std::string::assign(std::string const&) ()
from /lib64/libstdc++.so.6
#1 0x00007ffff734d465 in operator= (__str=..., this=0x7feb863a1b90)
at /usr/include/c++/4.9.2/bits/basic_string.h:555
#2 operator= (this=0x7feb863a1b90) at db/dbformat.h:204
#3 rocksdb::CompactionPicker::GetRange (this=0x7feb04015f40, inputs=...,
smallest=smallest@entry=0x7feb863a1b40, largest=largest@entry=0x7feb863a1b90)
at db/compaction/compaction_picker.cc:175
#4 0x00007ffff7357753 in PickFileToCompact (this=0x7feb863a1c30)
at db/compaction/compaction_picker_level.cc:511
#5 SetupInitialFiles (this=)
at db/compaction/compaction_picker_level.cc:213
#6 PickCompaction (this=0x7feb863a1c30) at db/compaction/compaction_picker_level.cc:351
#7 rocksdb::LevelCompactionPicker::PickCompaction (this=, cf_name=...,
mutable_cf_options=..., vstorage=, log_buffer=)
at db/compaction/compaction_picker_level.cc:555
#8 0x00007ffff732707c in rocksdb::ColumnFamilyData::PickCompaction (
this=this@entry=0x7feb0400f3d0, mutable_options=...,
log_buffer=log_buffer@entry=0x7feb863a2780) at db/column_family.cc:927
#9 0x00007ffff73939a3 in rocksdb::DBImpl::BackgroundCompaction (this=this@entry=
0x7feb04000b70, made_progress=made_progress@entry=0x7feb863a258e,
job_context=job_context@entry=0x7feb863a25b0,
log_buffer=log_buffer@entry=0x7feb863a2780,
prepicked_compaction=prepicked_compaction@entry=0x0, thread_pri=rocksdb::Env::LOW)
at db/db_impl/db_impl_compaction_flush.cc:2474
#10 0x00007ffff739ace3 in rocksdb::DBImpl::BackgroundCallCompaction (
this=this@entry=0x7feb04000b70, prepicked_compaction=prepicked_compaction@entry=0x0,
bg_thread_pri=bg_thread_pri@entry=rocksdb::Env::LOW)
at db/db_impl/db_impl_compaction_flush.cc:2245
#11 0x00007ffff739b2da in rocksdb::DBImpl::BGWorkCompaction (arg=)
at db/db_impl/db_impl_compaction_flush.cc:2021
#12 0x00007ffff75a51b7 in rocksdb::ThreadPoolImpl::Impl::BGThread (
this=this@entry=0xda3eb90, thread_id=thread_id@entry=0) at util/threadpool_imp.cc:266
#13 0x00007ffff75a540d in rocksdb::ThreadPoolImpl::Impl::BGThreadWrapper (
arg=0x7feb800020e0) at util/threadpool_imp.cc:307
#14 0x00007ffff4cd9e00 in ?? () from /lib64/libstdc++.so.6
#15 0x00007ffff595f52a in start_thread () from /lib64/libpthread.so.0
#16 0x00007ffff444322d in clone () from /lib64/libc.so.6

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.