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

Incomplete: Wake waiting tower-batch clones on close #1764

Merged
merged 3 commits into from Feb 17, 2021

Conversation

teor2345
Copy link
Contributor

@teor2345 teor2345 commented Feb 17, 2021

Motivation

tower-rs/tower#480 fixes tower's semaphore, to avoid a hang when clones are waiting on another dropped clone. The fix wakes waiting clones when another clone is dropped.

We should apply the same fix to tower-batch, which has a copy of tower's semaphore impl.

Solution

  • Copy semaphore.rs from our pinned version of tower to tower-batch
  • Update the header comment based on tokio 1.0
  • Add a missing Sync bound on the semaphore's future
  • Silence clippy unused code warnings

Review

We don't know if this hang is happening in practice, so this isn't urgent.

Related Issues

Closes #1671.

Follow Up Work

When we upgrade to tokio 1.0, we can use tokio_util::PollSemaphore, rather than copying this code from tower.

When other tower-batch tasks drop, wake any tasks that are waiting for
a semaphore permit. Otherwise, tower-batch can hang.

We currently pin tower in our workspace to:
d4d1c67 hedge: use auto-resizing histograms (tower-rs/tower#484)

Copy tower/src/semaphore.rs from that commit, to pick up
tower-rs/tower#480.
@teor2345 teor2345 added C-bug Category: This is a bug A-rust Area: Updates to Rust code C-enhancement Category: This is an improvement P-Medium I-hang A Zebra component stops responding to requests labels Feb 17, 2021
@teor2345 teor2345 added this to the 2021 Sprint 3 milestone Feb 17, 2021
@teor2345 teor2345 self-assigned this Feb 17, 2021
@teor2345 teor2345 added this to Review in progress in 🦓 via automation Feb 17, 2021
@teor2345 teor2345 removed this from the 2021 Sprint 3 milestone Feb 17, 2021
@dconnolly dconnolly merged commit 1ef836a into ZcashFoundation:main Feb 17, 2021
🦓 automation moved this from Review in progress to Done Feb 17, 2021
@teor2345 teor2345 mentioned this pull request Feb 23, 2021
18 tasks
@teor2345 teor2345 changed the title Wake waiting tower-batch clones on close Wake waiting tower-batch clones on close (incomplete) Feb 23, 2021
@teor2345
Copy link
Contributor Author

This fix was incomplete, for details see:
#1671 (comment)

@teor2345 teor2345 changed the title Wake waiting tower-batch clones on close (incomplete) Incomplete: Wake waiting tower-batch clones on close Feb 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-rust Area: Updates to Rust code C-bug Category: This is a bug C-enhancement Category: This is an improvement I-hang A Zebra component stops responding to requests
Projects
No open projects
🦓
  
Done
Development

Successfully merging this pull request may close these issues.

Update the semaphore impl in tower-batch, to avoid hangs
2 participants