Comments (6)
tower-balance
is the counter example.
In this case, tower-balance
holds a set of inner services. When Balance::poll_ready
is called, it in turn calls poll_ready
on all the inner services. When a request is received, it is dispatched to a ready inner service.
The problem is that poll_ready
has been called on all the inner services, which reserves capacity for a request. A request is only sent to one inner service. All the other inner services then have capacity for one request held in limbo, unable to be used for any other service clones. The capacity is not released until those other services are selected to receive requests.
Thoughts @olix0r
from tower.
The proposed and_then
solution smells a lot like it could introduce deadlock? Imagine two threads, 1 and 2, which try to call
two service in opposite orders. They both reserve the last (/only) slot in their "first" service, and will now wait forever to acquire a slot in the second.
from tower.
@jonhoo The existing (and really any concurrent code) is at risk of introducing deadlocks. Granted, this makes it a bit easier.
Given that the only other option (that I can think of) is unbounded buffering, I think it is a necessary hazard.
from tower.
Yeah, I mostly raised it because this seems like a pre-made deadlock trap, much like locks are, and should probably be documented as such. That's not to say I think we shouldn't have it β we should just make sure that users are aware that this can deadlock.
from tower.
This is implemented, but we need to document it better.
from tower.
Closing in favor of the doc meta issue (#33).
from tower.
Related Issues (20)
- Adding Service Wrapper that allows to share services for compatibility with Axum route layers HOT 4
- Support weights for request rate limiting HOT 1
- Can I ask one question? HOT 4
- Publish `0.5` release HOT 5
- `Retry<RetryPolicy, RateLimit<Client>>` does not work HOT 7
- Idea: Preventing Inappropriate Service Invocation HOT 1
- Returning a response from a tower layer HOT 2
- AsyncFilterLayer is missing Clone impl
- Have MakeBalance and MakeBalanceLayer example?
- `Reconnect::new()` Generic parameters are redundant HOT 2
- Adding option_layer causes trait bound unsastisfied HOT 1
- Publish release without pin-project (with pin-project-lite) HOT 4
- `tower::service_fn` docs don't say that you need the `util` flag HOT 3
- MQTT client adapter / framework HOT 1
- βFan outβ services? HOT 3
- Consider using `ControlFlow` for retry `Policy`.
- Extending `Building a middleware from scratch` guide
- breaking change in tower design (0.6 or beyond): first class support for async fn traits HOT 20
- unexpected behaviour of `RateLimit`
- experiment with permit based service framework HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tower.