-
Notifications
You must be signed in to change notification settings - Fork 86
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
Refactor tag assertion to FatalError check & Fix unexpected increase of tag #231
Conversation
Thanks for taking this on! I don't think this should be a separate "special" error type — many of the other existing error variants are just as fatal as this one. I think I'd be fine with just adding an error variant for tag mismatch and return that as an error like any other instead of panicking. |
Codecov Report
|
It's ok to flatten it. Is it possible that we specify out what are fatal / resumable / determines errors ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry it took me so long!
self.write_line(command.into_bytes().as_slice()) | ||
let result = self.write_line(command.into_bytes().as_slice()); | ||
if result.is_err() { | ||
self.tag -= 1; // rollback tag increase in create_command() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Following the discussion in #229, I'm okay with this change, though I think we should also add a skip_tag
method to Client
to allow manually incrementing the tag.
@@ -104,6 +104,8 @@ pub enum Error { | |||
/// In response to a STATUS command, the server sent OK without actually sending any STATUS | |||
/// responses first. | |||
MissingStatusResponse, | |||
/// Tag mismatch between client and server. New session must be created. | |||
TagCorrupted(TagCorrupted), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the name TagCorrupted
is misleading. A "corrupted" tag feels more like if a tag isn't a number for example, or has somehow otherwise been modified in-flight. What this represents (as the doc string indicates) is a TagMismatch
or Desynchronized
, so let's call it one of those.
fn description(&self) -> &str { | ||
"Tag is corrupted, session is in an inconsistent state" | ||
} | ||
|
||
fn cause(&self) -> Option<&dyn StdError> { | ||
None | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you can skip both of these fn
s — they're not required and their default implementations will do the right thing.
Is there anything I can do to to help this PR to be merged? I also encounter the same issue when retrying a
|
I think my comments above still stand, so it's really just a matter of making those changes. If @qsdgy is still interested in picking that up, then that's probably easiest, but if they're otherwise preoccupied or no longer need this, then feel free to open a new PR that builds on this one so we can land it 👍 |
I opened a new PR and tried to apply the changes your were requesting: #284 |
Closing this in favor of #284 👍 |
Try to turn tag assertion to an error check #230
Also straight forward fix #229
This change is![Reviewable](https://camo.githubusercontent.com/1541c4039185914e83657d3683ec25920c672c6c5c7ab4240ee7bff601adec0b/68747470733a2f2f72657669657761626c652e696f2f7265766965775f627574746f6e2e737667)