Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

coredump when destructor of BlobDBImpl called #5000

Open
yebangyu opened this issue Feb 18, 2019 · 1 comment
Open

coredump when destructor of BlobDBImpl called #5000

yebangyu opened this issue Feb 18, 2019 · 1 comment

Comments

@yebangyu
Copy link

yebangyu commented Feb 18, 2019

version of rocksdb: latest, master branch

how to reproduce:

int main() {
rocksdb::blob_db::BlobDB* db = nullptr;
auto status = rocksdb::blob_db::BlobDB::Open(db_options, db_opt, db_path,
column_families,&handles,&db);
assert(status.ok() && db);
for (int i = 0; i < 10000 ;++i) {db -> Put(random_string(), "world");}
delete db;
}

we run the program above about 1000000 times and it does cause 4 cores which have the same backtrace

the implementation of ~BlobDBImpl is :

BlobDBImpl::~BlobDBImpl() {
// CancelAllBackgroundWork(db_, true);
Status s attribute((unused)) = Close();
assert(s.ok());
}
Status BlobDBImpl::Close() {
// ...
delete db_;
//...
}

yeah , delete db_ no matter what it is , what happened and what is happening.

while ,it may cause data race . let's see:

std::pair<bool, int64_t> BlobDBImpl::EvictExpiredFiles(bool aborted) {
//...
SequenceNumber seq = GetLatestSequenceNumber();
// ...
}

GetLatestSequenceNumber may access invalid memory which is destroyed by ~BlobDBImpl

So, IMHO, yeah, yeah, it is up to users to make sure that there are no reads and writes when we delete db, while , the impl of ~BlobDBImpl needs to sync with the background threads in order to quit gracefully

@siying
Copy link
Contributor

siying commented Feb 21, 2019

#5005

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants