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

is HasBGError() strong enough when some error happened in LogAndApply #182

Open
lday0321 opened this issue Aug 2, 2020 · 2 comments
Open
Labels
component/titan Component: Titan engine status/help-wanted Status: Help wanted. Contributions are very welcome! type/bug Type: Issue - Confirmed a bug

Comments

@lday0321
Copy link

lday0321 commented Aug 2, 2020

we can see that a bg_error_ will be set when db_->blob_file_set_->LogAndApply(edit) return some error at db_impl.cpp:87. and the corresponding has_bg_error_ will be set to true as well to indicate that some bg error happend.

The lightweight flag has_bg_error_ is used to indicate whether some bg error happend and turn the whole db into read only mode and forbid subsequence read/write.

However, in HasBGError() do not hold the mutex_, but return the has_bg_error_ directly. I think there is a chance that some error has been happedn in LogAndApply and bg_error_ has been set to an error code, but has_bg_error_ is still false. In this scenario, the put/write from user is still allowed since HasBGError() return false at this point, then some unpredictable behavior will be happend, such as subsequent version edit will be apply to the manifest file and the manifest info on the disk and the manifest info in the memory (BlobFileSet) is not the same.

Could this be a bug in the titan? HasBGError() should hold the mutex_ as well?

@lance6716
Copy link

/label component/titan

@ti-srebot ti-srebot added the component/titan Component: Titan engine label Aug 3, 2020
@yiwu-arbug yiwu-arbug added the type/bug Type: Issue - Confirmed a bug label Aug 4, 2020
@yiwu-arbug
Copy link
Collaborator

yiwu-arbug commented Aug 4, 2020

Indeed we would need to double check HasBGError() while holding mutex_ before every time calling LogAndApply(). Do you mind sending a fix?

@yiwu-arbug yiwu-arbug added the status/help-wanted Status: Help wanted. Contributions are very welcome! label Aug 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/titan Component: Titan engine status/help-wanted Status: Help wanted. Contributions are very welcome! type/bug Type: Issue - Confirmed a bug
Projects
None yet
Development

No branches or pull requests

4 participants