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

reconnect during transaction #85

Closed
ikruglov opened this issue May 9, 2014 · 6 comments
Closed

reconnect during transaction #85

ikruglov opened this issue May 9, 2014 · 6 comments
Labels

Comments

@ikruglov
Copy link

ikruglov commented May 9, 2014

Found a nasty issue in the library.

Imagine:
MULTI
SET key1 1
SET key2 2
EXEC

If:

  1. client connects with reconnect option
  2. Redis server restarts between first and second SET

then client will successfully set key2.

ikruglov pushed a commit that referenced this issue May 9, 2014
@ikruglov
Copy link
Author

ikruglov commented May 9, 2014

the easiest way to solve this would be to disable MULTI and WATCH when in reconnect mode.
Not sure how other libraries solves the issue.

@ikruglov ikruglov added the bug label May 9, 2014
@tsee
Copy link
Member

tsee commented May 9, 2014

On 05/09/2014 03:30 PM, Ivan Kruglov wrote:

the easiest way to solve this would be to disable MULTI and WATCH when
in reconnect mode.
Not sure how other libraries solves the issue.

Or actually set flags on the client if we've seen MULTI/WATCH without
EXEC or (rollback/abort/whatever-it-is-called). And then when we
reconnect on a client during a transaction, we throw an exception or do
not reconnect. IOW "reconnect mode is disabled during transactions".

This is more work to do, but I think it is a better solution than "you
shall not have transactions on this handle at all".

--Steffen

@ikruglov
Copy link
Author

ikruglov commented May 9, 2014

yup, i've already started implementing this logic :-)

@trinitum
Copy link

trinitum commented May 9, 2014

On Fri, 09 May 2014 06:54:41 -0700
Steffen Müller notifications@github.com wrote:

On 05/09/2014 03:30 PM, Ivan Kruglov wrote:

Not sure how other libraries solves the issue.

Or actually set flags on the client if we've seen MULTI/WATCH without
EXEC or (rollback/abort/whatever-it-is-called). And then when we
reconnect on a client during a transaction, we throw an exception or
do not reconnect. IOW "reconnect mode is disabled during
transactions".

This is what RedisDB does, from the moment MULTI is sent to server and
till the moment EXEC/DISCARD is sent it will not reconnect. Although I
missed WATCH...

@dams
Copy link
Member

dams commented May 9, 2014

Thanks for looking into this. If possible I'd like to do a third dev release with a fix to this next week.

@dams
Copy link
Member

dams commented May 9, 2014

As a side note, I'm not too much convinced about the reconnect option usefulness. It makes some assumptions about the reconnection behavior, and doesn't provide any flexibility/configurability. Sometimes I'm tempted to dump the option altogether and dies with a proper exception and document the usage of Action::Retry or similar, to implement a real reconnect strategy. Any thought on that?

@dams dams closed this as completed in 7bb67e6 May 12, 2014
dams added a commit that referenced this issue May 12, 2014
   * release again, last one was screwed up.
   * fix #85 (PR #86) reconnect during transaction
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants