-
Notifications
You must be signed in to change notification settings - Fork 171
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
fix: broken tx retries for cluster clients after #697 #709
Conversation
return nil | ||
} | ||
count.m[p]++ | ||
count.m[cc]++ |
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.
make naming consistent.
break | ||
} | ||
} | ||
if last == cmds.InitSlot { | ||
return nil | ||
} | ||
} else if init { | ||
cc := c.pslots[last] | ||
count.m[cc] += inits |
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.
We don't count cmd.InitSlot commands to c.pslots[last]
in the code above this, so add the count back here.
dbe3db5
to
6bfd890
Compare
Find one extreme case:
We will get [4]RedisResult with all successful results. And resp[3] (which means EDIT: maybe we should find the nearest successful |
I just tried the double |
make sense though. BTW i got different response from redis:7.4 cluster cmd:
response
EDIT: |
6bfd890
to
f61ee99
Compare
for mi = i; mi >= 0 && !isMulti(commands[mi]) && !isExec(commands[mi]); mi-- { | ||
} | ||
for ei = i; ei < len(commands) && !isMulti(commands[ei]) && !isExec(commands[ei]); ei++ { | ||
} |
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.
Both mi
and ei
cursor will stop at either MULTI
or EXEC
to avoid crossing tx boundaries.
f61ee99
to
b4c543d
Compare
I tested these cases on Valkey 8, and they all failed with EXECABORT. But anyway, I think we should just not retry on these wired cases. |
LGTM mostly, but i have to test this PR again tomorrow |
Signed-off-by: Rueian <[email protected]>
b4c543d
to
fbdca04
Compare
cluster.go
Outdated
} | ||
for ei = i; ei < len(commands) && !isMulti(commands[ei]) && !isExec(commands[ei]); ei++ { | ||
} | ||
if mi >= 0 && mi < ei && ei < len(commands) && isMulti(commands[mi]) && isExec(commands[ei]) && resps[mi].val.string == ok { // a transaction is found. |
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.
If the nearest MULTI
didn't succeed, we don't retry the tx.
cluster.go
Outdated
} | ||
for ei = i; ei < len(commands) && !isMulti(commands[ei]) && !isExec(commands[ei]); ei++ { | ||
} | ||
if mi >= 0 && mi < ei && ei < len(commands) && isMulti(commands[mi]) && isExec(commands[ei]) && resps[mi].val.string == "QUEUED" { // a transaction is found. |
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.
resps[mi].val.string
should be OK
or just verify there is no error ?
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.
Yes, it should be OK
.
cluster.go
Outdated
continue // the transaction has been added to the retries, go to the next cmd. | ||
} | ||
} | ||
if hasInit && (mi < i && i < ei && mi >= 0 && isMulti(commands[mi]) || i > ei && ei >= 0 && isMulti(commands[ei])) { |
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.
isMulti(commands[ei])
maybe a typo ? should be isExec(commands[ei])
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.
It is not a typo. If commands[ei]
is a MULTI
then we should not retry the command on i
. However, I found that it is actually a dead code, i
will never be larger than ei
at this point, so the condition is removed now.
443734d
to
aafed64
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.
LGTM 👍
IMO we should publish a release for it. |
Signed-off-by: Rueian <[email protected]>
aafed64
to
e5cfe35
Compare
Signed-off-by: Rueian <[email protected]>
9792175
to
060a937
Compare
Yeap, but we just forget handling ASKING correctly. I have made a new commit for it. |
No description provided.