-
Notifications
You must be signed in to change notification settings - Fork 60
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
Extend ring.DoBatch's error class tracking to all errors #427
Conversation
ebc9ed8
to
04da612
Compare
…g.Error Signed-off-by: Yuri Nikolic <durica.nikolic@grafana.com>
04da612
to
6e63c99
Compare
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.
Thanks for working on this. I left a few comments, but the change looks mostly good
ring/batch.go
Outdated
if itemTracker.done.Load() { | ||
continue | ||
} |
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.
what's the reason for this change?
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.
My idea was to set the new done
attribute of an itemTracker
to true as soon as that itemTracker
reaches either its minSuccess
or its maxFailure
. Once it is achieved, we don't need to consider that itemTracker
anymore.
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.
As discussed via slack, this will be done in a separate PR, and maybe in a different form. I have reverted this part of the PR.
I would suggest simpler design: passing a function to |
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.
the tests look better as table tests 👌
Passing a function will probably create fewer allocations for the client of the library. But I feel like the interface of DoBatch will become more complex. It already takes one function argument which returns an error. Now it will have another func arg which will receive the same error and return a boolean. I feel like an optional interface on the returned error is less invasive and more straight forward. |
|
I have opted for this solution. |
Signed-off-by: Yuri Nikolic <durica.nikolic@grafana.com>
5d557da
to
43219bf
Compare
Signed-off-by: Yuri Nikolic <durica.nikolic@grafana.com>
Signed-off-by: Yuri Nikolic <durica.nikolic@grafana.com>
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.
thanks for addressing my comments
Signed-off-by: Yuri Nikolic <durica.nikolic@grafana.com>
41f6d41
to
4a6700e
Compare
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.
Thank you. Left some small suggestions for consideration.
Signed-off-by: Yuri Nikolic <durica.nikolic@grafana.com>
What this PR does:
Error class tracking has been added to
ring.DoBatch()
in #201. That PR introduced 2 classes of errors:itemTracker.failed4xx
), anditemTracker.failed5xx
).Unfortunately, this change took into account only errors with an HTTP status. In case of a gRPC error, or any other error not implementing
GRPCStatus() *Status
fromgoogle.golang.org/grpc/status
, the error was implicitly treated as a server error. For example, if ring instances from a replication set return gRPC errors with gRPC codesFailedPrecondition
(due to a client problem),FailedPrecondition
(do to a client problem) andUnavailable
(do to a server being currently unavailable), the current approach would return the last error that arrived, i.e., the serverUnavailable
error, although the majority of the instances would have given the clientFailedPrecondition
error.Main change
This PR fixes that problem by introducing a new function,
which is a generalization of
ring.DoBatch()
that has an additional parameterisClientError
, a function specified by the caller that differentiates between client and server errors.Minor changes
itemTracker
's attributesfailed4xx
andfailed5xx
have been renamed tofailedClient
andfailedServer
.Which issue(s) this PR fixes:
Part of grafana/mimir#6008
Checklist
CHANGELOG.md
updated - the order of entries should be[CHANGE]
,[FEATURE]
,[ENHANCEMENT]
,[BUGFIX]