-
-
Notifications
You must be signed in to change notification settings - Fork 274
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
Recovering from errors during writes #229
Comments
If you can't afford buffering, my proposed solution would be to create your own This does mean that you do wind up going through the effort of serializing a lot of your content into the void when you don't really need to, but I don't think that there's any other way to solve this given Bincodes constraints. |
I guess such a wrapper would also need to know when serialization starts and finishes (i.e., the first and last write of a serialization) so that it knows when to start dropping, and when to reset The alternative proposal here would be for bincode to keep track of its serialization progress somehow, but that would likely also come with some pretty substantial API changes that we'd want to avoid. This should probably be mentioned in the docs for |
Yep!
Also, because bincode uses Serde for serialization/deserialization, it would require breaking Serde changes. Last time I talked to them, they have no plans to ever break API compat.
For this error in particular, could you have Write wrapper that retries the internal write call on
|
And yeah, this would be a good thing to document, thanks for bringing it up! |
Yes, that would work. This is basically what |
Previously, send_back would not block on WouldBlock or Interrupted, and would silently just not send acks to the clients. That's be bad. This commit fixes that. See also bincode-org/bincode#229. This has the unfortunate side-effect of introducing a race between mutators and domains. If a mutator doesn't wait for acks sufficiently often, it may end up blocking on sending to the domain, while the domain is blocking on sending acks to the client. It *also* means that domains now wait for slow clients...
Closing since it seems that this is best solved by an external |
In most cases, a write to an
io::Write
will only fail if the writer is no longer valid. In those cases, the is no reason to continue writing, and the serialization should simply be aborted. However, in other cases, it would be useful to resume a write into anio::Write
following an error. This applies particularly to transient errors likeErrorKind::TimedOut
,ErrorKind::WouldBlock
, andErrorKind::Interrupted
.Unfortunately, since bincode currently writes things out piece by piece (and calls into the writer multiple times) without keeping track of how far it has gotten, resuming from these errors is basically impossible. One has to first serialize the value into a
Vec<u8>
, and then write from that value into the underlying writer, which introduces some unfortunate double-buffering.What's the proposed solution for handling these kinds of errors?
The text was updated successfully, but these errors were encountered: