Skip to content

WC: fix for stop while shutting down - #499

Merged
Yuval-Ariel merged 3 commits into
mainfrom
check-shutting-down-inside-WC-WaitOnCV
May 24, 2023
Merged

Yuval-Ariel merged 3 commits into
mainfrom
check-shutting-down-inside-WC-WaitOnCV

Conversation

@Yuval-Ariel

Copy link
Copy Markdown
Contributor

as part of meta/rocksdb#10765 , a check of whether the waiting db was shutting_down_ was intoduced.
The write thread then stops waiting when shutting_down_ is turned on which is the case when CancelAllBackgroundWork is called. But the rebased code now waits forever since #346 replaced the waiting on bg_cv_ to a wait on a write controller condition variable inside WriteController::WaitOnCV.
The condition variable inside WaitOnCV (stop_cv_) is only notified through the detor of a StopWriteToken.

The write_controller_token_ in each CF is being reset in any case after the call to CancelAllBackgroundWork from DBImpl::CloseHelper() (detor of DBImpl) so if the test would issue a db Close and then wait for the thread there would be no problem.

also consider fixing by instead of replacing CancelAllBackgroundWork with Close, to add a function right after the call to CancelAllBackgroundWork which notifies the stop_cv_ . this will make it clear to further unit test writers that calling CancelAllBackgroundWork is not sufficient in order to remove the stop condition

@Yuval-Ariel Yuval-Ariel added the bug fix Fixes a known bug label May 10, 2023
@Yuval-Ariel
Yuval-Ariel requested a review from udi-speedb May 10, 2023 10:28
@Yuval-Ariel Yuval-Ariel self-assigned this May 10, 2023
@Yuval-Ariel

Copy link
Copy Markdown
Contributor Author

@udi-speedb , plz wait with the review since changing CancelAllBackgroundWork to Close seemed to reveal a new issue which is handled in #500 .
setting this PR to on hold until the above issue is fixed

@Yuval-Ariel
Yuval-Ariel force-pushed the 8-1-1-rebase-main-candidate branch from 3349f79 to 2ffee5b Compare May 11, 2023 05:43
@Yuval-Ariel
Yuval-Ariel changed the base branch from 8-1-1-rebase-main-candidate to main May 11, 2023 06:07
@Yuval-Ariel

Copy link
Copy Markdown
Contributor Author

also need to include a notify on the write controllers condition variable when there a BG error (SetBGError)

@Yuval-Ariel Yuval-Ariel changed the title WC: fix for stop while during shutting down WC: fix for stop while shutting down May 14, 2023
@Yuval-Ariel
Yuval-Ariel force-pushed the check-shutting-down-inside-WC-WaitOnCV branch from 2e4894b to c4efc92 Compare May 14, 2023 09:07
@Yuval-Ariel

Copy link
Copy Markdown
Contributor Author

@udi-speedb , plz review. issue #500 is still unresolved as it requires further discussion so we can proceed with this PR IMO.

@udi-speedb

Copy link
Copy Markdown
Contributor

@Yuval-Ariel - Approving.
Just a reminder - Did you go over all the places where CancelAllBackgroundWork() is called to verify that no need to call ResetWriteControllerTokens()?

@Yuval-Ariel

Copy link
Copy Markdown
Contributor Author

Just a reminder - Did you go over all the places where CancelAllBackgroundWork() is called to verify that no need to call ResetWriteControllerTokens()?

yes i did

@Yuval-Ariel

Copy link
Copy Markdown
Contributor Author

@erez-speedb , plz check that theres no degradation. thanks

@Yuval-Ariel

Copy link
Copy Markdown
Contributor Author

performance - no degradation.
still need to update history file

Also switch to waiting a sec on the CV each time. This is required
since a bg error doesn't signal the CV in the WriteController.
@Yuval-Ariel
Yuval-Ariel force-pushed the check-shutting-down-inside-WC-WaitOnCV branch from fd1a5c6 to 37b91b6 Compare May 24, 2023 06:49
@Yuval-Ariel
Yuval-Ariel merged commit 5bcecf0 into main May 24, 2023
@Yuval-Ariel
Yuval-Ariel deleted the check-shutting-down-inside-WC-WaitOnCV branch May 24, 2023 06:55
udi-speedb pushed a commit that referenced this pull request Nov 19, 2023
Also switch to waiting a sec on the CV each time. This is required
since a bg error doesn't signal the CV in the WriteController.
udi-speedb pushed a commit that referenced this pull request Dec 5, 2023
Also switch to waiting a sec on the CV each time. This is required
since a bg error doesn't signal the CV in the WriteController.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug fix Fixes a known bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants