Skip to content

Commit f27b4cf

Browse files
committed
Improve error handling of transaction::commit_or_rollback_by_xid()
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.
1 parent e2b3e99 commit f27b4cf

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

src/transaction.cpp

+16-2
Original file line numberDiff line numberDiff line change
@@ -1136,8 +1136,22 @@ int wsrep::transaction::commit_or_rollback_by_xid(const wsrep::xid& xid,
11361136

11371137
if (!sa)
11381138
{
1139-
assert(sa);
1140-
client_state_.override_error(wsrep::e_error_during_commit);
1139+
enum wsrep::provider::status status;
1140+
if (server_state.state() == wsrep::server_state::s_disconnected)
1141+
{
1142+
// The node has disconnected from the cluster, and has closed
1143+
// all streaming appliers. We can't tell if a transaction with
1144+
// corresponding xid exists. In any case, we can't do much
1145+
// while disconnected, the client should retry.
1146+
status = wsrep::provider::error_connection_failed;
1147+
}
1148+
else
1149+
{
1150+
// The xid never existed, or it was already committed or
1151+
// rolled back.
1152+
status = wsrep::provider::error_transaction_missing;
1153+
}
1154+
client_state_.override_error(wsrep::e_error_during_commit, status);
11411155
return 1;
11421156
}
11431157

0 commit comments

Comments
 (0)