-
Notifications
You must be signed in to change notification settings - Fork 177
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
ai/live: Add limited retries for segment publish #3315
Conversation
d70bf24
to
0fe6170
Compare
Only retry if the error occurs before sending any data, and if the next segment hasn't arrived yet.
0fe6170
to
3cae6f1
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #3315 +/- ##
===================================================
- Coverage 33.92247% 33.86599% -0.05648%
===================================================
Files 141 141
Lines 37173 37235 +62
===================================================
Hits 12610 12610
- Misses 23843 23905 +62
Partials 720 720
Continue to review full report in Codecov by Sentry.
|
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.
lgtm
} | ||
clog.Infof(ctx, "Error publishing segment before writing; retrying err=%v", err) | ||
// Clone in case read head was incremented somewhere, which cloning ressets | ||
r = reader.Clone() |
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.
Hmm this seems maybe not 100% guaranteed, since it could happen that something was read from the reader and then failed to be sent to the writer (and we got 0
on L89).
I think there's no really easy option here apart from maybe an additional layer to check if the reader was used at some point, like a wrapped reader that flags if it was read. A built-in approach could be using a io.TeeReader
to read into a buffer as we read from the input (which would also allow us to retry when some bytes have been read).
Anyway, if you think this is too much of a corner case, this LGTM as it's much simpler. But I think that conceptually it could still have this issue 🤔
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.
since it could happen that something was read from the reader and then failed to be sent to the writer (and we got 0 on L89).
That is basically why we call Clone()
(which resets the read head for the clone) so when we try to read it during the next iteration, it is starting from the beginning, regardless of the actual read head. Note that this isn't a "standard" IO reader but rather something specialized that allows for clean resets, nonblocking reads/writes, multiple readers, etc, without having to go through hoops like TeeReader.
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.
Ohh that's cool! Didn't know we already had that custom impl. Pretty neat :)
Only retry if the error occurs before sending any data, and if the next segment hasn't arrived yet.
Depends on #3308