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

Backport #50387 to 23.4: Fix Keeper deadlock on exception when preprocessing requests. #50505

Merged
merged 1 commit into from Jun 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 10 additions & 1 deletion src/Coordination/KeeperStateMachine.cpp
Expand Up @@ -219,7 +219,8 @@ bool KeeperStateMachine::preprocess(const KeeperStorage::RequestForSession & req
}
catch (...)
{
rollbackRequest(request_for_session, true);
tryLogCurrentException(__PRETTY_FUNCTION__);
rollbackRequestNoLock(request_for_session, true);
throw;
}

Expand Down Expand Up @@ -344,6 +345,14 @@ void KeeperStateMachine::rollbackRequest(const KeeperStorage::RequestForSession
storage->rollbackRequest(request_for_session.zxid, allow_missing);
}

void KeeperStateMachine::rollbackRequestNoLock(const KeeperStorage::RequestForSession & request_for_session, bool allow_missing)
{
if (request_for_session.request->getOpNum() == Coordination::OpNum::SessionID)
return;

storage->rollbackRequest(request_for_session.zxid, allow_missing);
}

nuraft::ptr<nuraft::snapshot> KeeperStateMachine::last_snapshot()
{
/// Just return the latest snapshot.
Expand Down
2 changes: 2 additions & 0 deletions src/Coordination/KeeperStateMachine.h
Expand Up @@ -53,6 +53,8 @@ class KeeperStateMachine : public nuraft::state_machine
// (can happen in case of exception during preprocessing)
void rollbackRequest(const KeeperStorage::RequestForSession & request_for_session, bool allow_missing);

void rollbackRequestNoLock(const KeeperStorage::RequestForSession & request_for_session, bool allow_missing);

uint64_t last_commit_index() override { return last_committed_idx; }

/// Apply preliminarily saved (save_logical_snp_obj) snapshot to our state.
Expand Down