Skip to content
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

Raise errors from #pipelined instead of returning them #297

Merged

Conversation

KJTsanaktsidis
Copy link
Contributor

It seems redis-cluster-client intentionally decides to return errors from #pipelined, rather than raising them. I note that in #37 it was written:

In Grab’s Redis Cluster library, the function
Pipeline(PipelineReadOnly) returns a response with an error for
individual reply.
Instead of returning nil or an error message when err != nil, we could
check for errors for each result so successful queries are not affected.
This might have minimised the outage’s business impact.

I prefer the above behavior.

It's certainly true that returning the individual results from pipelined gives strictly more information than raising an exception. UNFORTUNATELY, redis-client chooses the opposite option; if any query caused an error, after processing the entire pipeline it raises rather than returns; see:
https://github.com/redis-rb/redis-client/blob/932c5e8909ede7575d56a117773be39f40e2da88/lib/redis_client/connection_mixin.rb#L60

I think consistency with redis-client is very valuable to have for redis-cluster-client, so I would suggest that changing the behaviour here (perhaps with a major version bump?) might be a good idea?

Alternatively, althought I think this would be even more confusing IMO, we could keep the error handling as-is here but patch it in redis-rb to raise instead of return.

It seems redis-cluster-client intentionally decides to return errors
from #pipelined, rather than raising them. I note that in
redis-rb#37
it was written:

>> In Grab’s Redis Cluster library, the function
>> Pipeline(PipelineReadOnly) returns a response with an error for
>> individual reply.
>> Instead of returning nil or an error message when err != nil, we could
>> check for errors for each result so successful queries are not affected.
>> This might have minimised the outage’s business impact.
>
> I prefer the above behavior.

It's certainly true that returning the individual results from
pipelined gives strictly more information than raising an exception.
UNFORTUNATELY, redis-client chooses the _opposite_ option; if any query
caused an error, after processing the entire pipeline it raises rather
than returns; see:
https://github.com/redis-rb/redis-client/blob/932c5e8909ede7575d56a117773be39f40e2da88/lib/redis_client/connection_mixin.rb#L60

I think consistency with redis-client is very valuable to have for
redis-cluster-client, so I would suggest that changing the behaviour
here (perhaps with a major version bump?) might be a good idea?

Alternatively, althought I think this would be even _more_ confusing
IMO, we could keep the error handling as-is here but patch it in
redis-rb to raise instead of return.
@supercaracal supercaracal self-requested a review November 17, 2023 07:01
Copy link
Member

@supercaracal supercaracal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your pull request. Our redis-cluster-client aims behavior same as redis-client as possible. The error handling of pipelining might be changed in the future, but I'd say that it would be better to behave same now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants