Skip to content

Commit

Permalink
Improve error handling of transaction::commit_or_rollback_by_xid()
Browse files Browse the repository at this point in the history
Handle the case where a call to commit_or_rollback_by_xid() is given
a xid for which there is no corresponding streaming applier.
We distinguish two cases here:
1) the xid might not exist at all, or the corresponding transaction
was already committed or rolled back. The client may just return an
error; or 2) all streaming appliers have been closed
because the node is currently disconnected. We can't tell if a
corresponding transaction exists. The client may want to retry.
  • Loading branch information
sciascid committed Nov 12, 2021
1 parent e2b3e99 commit f27b4cf
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/transaction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1136,8 +1136,22 @@ int wsrep::transaction::commit_or_rollback_by_xid(const wsrep::xid& xid,

if (!sa)
{
assert(sa);
client_state_.override_error(wsrep::e_error_during_commit);
enum wsrep::provider::status status;
if (server_state.state() == wsrep::server_state::s_disconnected)
{
// The node has disconnected from the cluster, and has closed
// all streaming appliers. We can't tell if a transaction with
// corresponding xid exists. In any case, we can't do much
// while disconnected, the client should retry.
status = wsrep::provider::error_connection_failed;
}
else
{
// The xid never existed, or it was already committed or
// rolled back.
status = wsrep::provider::error_transaction_missing;
}
client_state_.override_error(wsrep::e_error_during_commit, status);
return 1;
}

Expand Down

0 comments on commit f27b4cf

Please sign in to comment.