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

Seg fault when closing a db while writing to it #500

Closed
Yuval-Ariel opened this issue May 10, 2023 · 2 comments
Closed

Seg fault when closing a db while writing to it #500

Yuval-Ariel opened this issue May 10, 2023 · 2 comments
Assignees
Labels
bug Something isn't working To review A feature request that has not been reviewed yet

Comments

@Yuval-Ariel
Copy link
Contributor

error:

[ RUN      ] DBTest.ShuttingDownNotBlockStalledWrites
Received signal 11 (Segmentation fault)

#4  0x00007fc783ad2827 in rocksdb::DBImpl::PreprocessWrite (this=0x55fc370d06c0, write_options=..., log_context=0x7fc7497f8f50, write_context=0x7fc7497f9310) at db/db_impl/db_impl_write.cc:1254
1254	  log_context->writer = logs_.back().writer;
#5  0x00007fc783acd8aa in rocksdb::DBImpl::WriteImpl (this=0x55fc370d06c0, write_options=..., my_batch=0x7fc7497f96c0, callback=0x0, log_used=0x0, log_ref=0, disable_memtable=false, seq_used=0x0, batch_cnt=0, pre_release_callback=0x0, post_memtable_callback=0x0) at db/db_impl/db_impl_write.cc:391
391	    status = PreprocessWrite(write_options, &log_context, &write_context);
#6  0x00007fc783acc5cb in rocksdb::DBImpl::Write (this=0x55fc370d06c0, write_options=..., my_batch=0x7fc7497f96c0) at db/db_impl/db_impl_write.cc:146
146	    s = WriteImpl(write_options, my_batch, /*callback=*/nullptr,

the main thread has already returned from Close().

reproduce:
on hash 3349f79
in db/db_test.cc, ShuttingDownNotBlockStalledWrites test, change call to CancelAllBackgroundWork(db_, true); into Close();

need to check if its Upstreamable

@Yuval-Ariel Yuval-Ariel added the bug Something isn't working label May 10, 2023
@Yuval-Ariel Yuval-Ariel self-assigned this May 10, 2023
@Yuval-Ariel Yuval-Ariel added the To review A feature request that has not been reviewed yet label May 14, 2023
@Yuval-Ariel
Copy link
Contributor Author

From looking at the code, it seems that currently its not supported to close the db while theres a live put request in process.
this could be the result of facebook/rocksdb@1e9bf25#diff-d9341fbe2a5d4089b93b22c5ed7f666bc311b378c26d0786f4b50c290e460187 since the db mutex is not protecting the part of the PreprocessWrite anymore.
in any case, i think we need to understand whether its the users responsibility for waiting until the Put operation returns before calling Close() or destroying the db.

any thoughts @Guyme , @hilikspdb ?

i've also raised this issue In the RocksDB repo - facebook/rocksdb#10751 . waiting for their reply

@Yuval-Ariel
Copy link
Contributor Author

found an answer is rocksdb QnA.:

Q: Is it safe to close RocksDB while another thread is issuing read, write or manual compaction requests?

A: No. The users of RocksDB need to make sure all functions have finished before they close RocksDB. You can speed up the waiting by calling CancelAllBackgroundWork().

@Yuval-Ariel Yuval-Ariel closed this as not planned Won't fix, can't repro, duplicate, stale May 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working To review A feature request that has not been reviewed yet
Projects
None yet
Development

No branches or pull requests

1 participant