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

Stalled writes block forever during shutting down #10751

Closed
qingping209 opened this issue Sep 28, 2022 · 4 comments
Closed

Stalled writes block forever during shutting down #10751

qingping209 opened this issue Sep 28, 2022 · 4 comments
Labels
bug Confirmed RocksDB bugs

Comments

@qingping209
Copy link
Contributor

qingping209 commented Sep 28, 2022

in the following code, the Put operation block forever.

https://gist.github.com/qingping209/356febd14f2d7db7b46212b11477ebf4

here is my reasoning:

  1. the db has too many level0 files, and the Put operation blocks
  2. the scheduled background compaction is supposed to clear the stop write condition once it's finished
  3. before the scheduled background compaction finished, a CancelAllBackgroundWork(true) is called
  4. the blocked Put is wake up and recheck the stop write condition in DelayWrite, and the stop write condition is not clear;
  5. the Put block in the DelayWrite again.

A possible fix is to check the shutting_down_ variable in this line: https://github.com/facebook/rocksdb/blob/main/db/db_impl/db_impl_write.cc#L1787

and return Status::ok() at https://github.com/facebook/rocksdb/blob/main/db/db_impl/db_impl_write.cc#L1787
if shutting_down_ is set.

@qingping209 qingping209 changed the title CancelAllBackgroundWork does not return when there's ingestion and write stalls Delayed writes block forever after CancelAllBackgroundWork(false) called Sep 29, 2022
@qingping209 qingping209 changed the title Delayed writes block forever after CancelAllBackgroundWork(false) called Delayed writes block forever after CancelAllBackgroundWork called Sep 30, 2022
@qingping209
Copy link
Contributor Author

@ajkr @siying can you take a brief look ?

@cbi42
Copy link
Member

cbi42 commented Sep 30, 2022

Hi @qingping209 , the analysis makes sense to me, would you like to contribute a fix?

@cbi42 cbi42 added the bug Confirmed RocksDB bugs label Sep 30, 2022
@qingping209
Copy link
Contributor Author

Hi @qingping209 , the analysis makes sense to me, would you like to contribute a fix?

sure.

@qingping209 qingping209 changed the title Delayed writes block forever after CancelAllBackgroundWork called Stalled writes block forever after CancelAllBackgroundWork called Oct 1, 2022
@qingping209 qingping209 changed the title Stalled writes block forever after CancelAllBackgroundWork called Stalled writes block forever when shutting down called Oct 1, 2022
@qingping209 qingping209 changed the title Stalled writes block forever when shutting down called Stalled writes block forever during shutting down Oct 1, 2022
@Yuval-Ariel
Copy link

Hey @cbi42 ,
Is it correct to deduce that its valid to close the db while another thread is writing to it?
Im asking because CancelAllBackgroundWork is only a part of the Close() operation.

Thanks!

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

Successfully merging a pull request may close this issue.

3 participants