Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Use std::sync::Condvar #1732

Merged
merged 1 commit into from
Jul 27, 2016
Merged

Use std::sync::Condvar #1732

merged 1 commit into from
Jul 27, 2016

Conversation

arkpar
Copy link
Collaborator

@arkpar arkpar commented Jul 26, 2016

Apparently there's a bug in the parking_lot resulting in the thread being stuck forever in Condvar::wait on windows.
Reverted to std::sync::Condvar for now.

@arkpar arkpar added the A0-pleasereview 🤓 Pull request needs code review. label Jul 26, 2016
@coveralls
Copy link

coveralls commented Jul 26, 2016

Coverage Status

Coverage increased (+0.1%) to 87.129% when pulling f4d257f on fix-condvar into a9ae6e3 on master.

@coveralls
Copy link

coveralls commented Jul 26, 2016

Coverage Status

Coverage increased (+0.1%) to 87.145% when pulling f4d257f on fix-condvar into a9ae6e3 on master.

@@ -123,7 +123,7 @@ impl Worker {
impl Drop for Worker {
fn drop(&mut self) {
trace!(target: "shutdown", "[IoWorker] Closing...");
let _ = self.wait_mutex.lock();
let _ = self.wait_mutex.lock().unwrap();
self.deleting.store(true, AtomicOrdering::Release);
self.wait.notify_all();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if the issue is that this call happens before the atomic store due to compiler or CPU isntruction reordering.
System condvars can have spurious wakeups, but parking_lot ones can't. I don't have a windows machine right now, but could you test using parking_lot and adding a call to atomic::fence(AtomicOrdering::SeqCst) between the store to deleting and the condvar notification?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It has nothing to do with deleting as it does not change when the deadlock happens

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If deleting hasn't changed, then the deadlock is in the mutex, isn't it?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems to be related to mutex unlocking on wait. It is hard to tell cause the logic inside is quite complex. I'll see if I can create an example and file an issue.

@rphmeier
Copy link
Contributor

Also, we should avoid closing #1726 until we are 100% sure that the issue is indeed fixed...

while !deleting.load(AtomicOrdering::Acquire) {
{
let mut unverified = verification.unverified.lock();
let mut more_to_verify = verification.more_to_verify.lock().unwrap();
Copy link
Collaborator

@tomusdrw tomusdrw Jul 27, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are also some logical changes here (and in flush). I'm just making sure it's intended, is it?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've used a different mutex for a Condvar so that verification structures would continue using parking_lot mutex.

@gavofyork gavofyork added A8-looksgood 🦄 Pull request is reviewed well. and removed A0-pleasereview 🤓 Pull request needs code review. labels Jul 27, 2016
@gavofyork gavofyork merged commit c65ee93 into master Jul 27, 2016
@gavofyork gavofyork deleted the fix-condvar branch July 27, 2016 09:39
ordian added a commit to ordian/parity that referenced this pull request Aug 21, 2018
ordian added a commit to ordian/parity that referenced this pull request Aug 21, 2018
ordian added a commit to ordian/parity that referenced this pull request Aug 21, 2018
debris pushed a commit that referenced this pull request Aug 22, 2018
* Revert "Use std::sync::Condvar (#1732)"

This reverts commit c65ee93.

* verification_queue: remove redundant mutexes
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A8-looksgood 🦄 Pull request is reviewed well.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants