-
Notifications
You must be signed in to change notification settings - Fork 387
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
Transaction Commit retries cause _check_tx_state to raise ValueError #757
Comments
Hi,
I will try to have a closer look at it over the weekend but, at first
glance, the intended behavior is to set "committed" while sending the
transaction, so that the client doesn't send multiple duplicate transaction
requests to the server, and let the KazooRetry handle retransmission. You
are not supposed to reuse the transaction after it fails (or succeeds).
But I need a little more time to sit down and review your bug report to be
certain.
Thanks,
…On Fri, Oct 18, 2024, 13:12 An ***@***.***> wrote:
Sorry, I'm not familiar with Kazoo implementation of async, but is it
possible to fix this by replacing committed with threading.Lock ?
def commit_async(self):
"""Commit the transaction asynchronously.
:rtype: :class:`~kazoo.interfaces.IAsyncResult`
"""
with self.commit_lock:
self._check_tx_state()
async_object = self.client.handler.async_result()
self.client._call(Transaction(self.operations), async_object)
self.committed = True
return async_object
—
Reply to this email directly, view it on GitHub
<#757 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAIFTHWI2NOETCUN7RLA6S3Z4E6PDAVCNFSM6AAAAABQFBFZDWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDIMRSHEYDKNZVG4>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
The current behaviour of TransactionRequest is to set committed before making the connection. This makes subsequent calls to TransactionRequest.commit throw ValueError. KazooRetry will then just give up after the first failed connection apparently.
I agree. One thing though. I think it conflicts with the role of using KazooRetry.retry:
We could either fix this by setting committed to False in the retry loop or add a documentation that KazooRetry is not meant for TransactionRequest. Both of which scream of technical debt for me. |
Expected Behavior
When the connection is bad, KazooClient should try to commit the transaction again. The state of committed before the retry attempt should be False, because zookeeper did not actually commit this transaction. Or KazooRetry should be able to reset committed when encounter retry-able connection-related errors.
Actual Behavior
Transaction is set as committed. Subsequent attempts by KazooRetry cause Transaction to raise ValueError due to _check_tx_state. This is due to commit_async setting committed to true before making the connection.
The problem is a result from the current intention for committed:
This requires manually retrying to commit TransactionRequest.
Snippet to Reproduce the Problem
Logs with logging in DEBUG mode
Error raised: ValueError("Transaction already committed")
Specifications
The text was updated successfully, but these errors were encountered: