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

Improve error handling of transaction::commit_or_rollback_by_xid() #171

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 28 additions & 5 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 Expand Up @@ -1517,6 +1531,8 @@ int wsrep::transaction::certify_fragment(
flags(flags() | wsrep::provider::flag::implicit_deps);
}

client_service_.debug_sync("wsrep_before_fragment_append");

int ret(0);
enum wsrep::client_error error(wsrep::e_success);
enum wsrep::provider::status cert_ret(wsrep::provider::success);
Expand All @@ -1535,14 +1551,21 @@ int wsrep::transaction::certify_fragment(
// available to store the fragment. The fragment meta data
// is updated after certification.
wsrep::id server_id(client_state_.server_state().id());
assert(server_id.is_undefined() == false);
if (storage_service.start_transaction(ws_handle_) ||
if (server_id.is_undefined())
{
// we can't append a fragment with undefined server_id
// server has disconnected?
ret = 1;
error = wsrep::e_append_fragment_error;
}

if (!ret && (storage_service.start_transaction(ws_handle_) ||
storage_service.append_fragment(
server_id,
id(),
flags(),
wsrep::const_buffer(data.data(), data.size()),
xid()))
xid())))
{
ret = 1;
error = wsrep::e_append_fragment_error;
Expand Down