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

[v23.3.x] k/group_manager: return not_coordinator quickly in tx operations #23187

Merged
Merged
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
24 changes: 20 additions & 4 deletions src/v/kafka/server/group_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1253,7 +1253,11 @@ group_manager::leave_group(leave_group_request&& r) {
ss::future<txn_offset_commit_response>
group_manager::txn_offset_commit(txn_offset_commit_request&& r) {
auto p = get_attached_partition(r.ntp);
if (!p || !p->catchup_lock->try_read_lock()) {
if (!p || !p->partition->is_leader()) {
return ss::make_ready_future<txn_offset_commit_response>(
txn_offset_commit_response(r, error_code::not_coordinator));
}
if (!p->catchup_lock->try_read_lock()) {
// transaction operations can't run in parallel with loading
// state from the log (happens once per term change)
vlog(
Expand Down Expand Up @@ -1304,7 +1308,11 @@ group_manager::txn_offset_commit(txn_offset_commit_request&& r) {
ss::future<cluster::commit_group_tx_reply>
group_manager::commit_tx(cluster::commit_group_tx_request&& r) {
auto p = get_attached_partition(r.ntp);
if (!p || !p->catchup_lock->try_read_lock()) {
if (!p || !p->partition->is_leader()) {
return ss::make_ready_future<cluster::commit_group_tx_reply>(
make_commit_tx_reply(cluster::tx_errc::not_coordinator));
}
if (!p->catchup_lock->try_read_lock()) {
// transaction operations can't run in parallel with loading
// state from the log (happens once per term change)
vlog(
Expand Down Expand Up @@ -1343,7 +1351,11 @@ group_manager::commit_tx(cluster::commit_group_tx_request&& r) {
ss::future<cluster::begin_group_tx_reply>
group_manager::begin_tx(cluster::begin_group_tx_request&& r) {
auto p = get_attached_partition(r.ntp);
if (!p || !p->catchup_lock->try_read_lock()) {
if (!p || !p->partition->is_leader()) {
return ss::make_ready_future<cluster::begin_group_tx_reply>(
make_begin_tx_reply(cluster::tx_errc::not_coordinator));
}
if (!p->catchup_lock->try_read_lock()) {
// transaction operations can't run in parallel with loading
// state from the log (happens once per term change)
vlog(
Expand Down Expand Up @@ -1391,7 +1403,11 @@ group_manager::begin_tx(cluster::begin_group_tx_request&& r) {
ss::future<cluster::abort_group_tx_reply>
group_manager::abort_tx(cluster::abort_group_tx_request&& r) {
auto p = get_attached_partition(r.ntp);
if (!p || !p->catchup_lock->try_read_lock()) {
if (!p || !p->partition->is_leader()) {
return ss::make_ready_future<cluster::abort_group_tx_reply>(
make_abort_tx_reply(cluster::tx_errc::not_coordinator));
}
if (!p->catchup_lock->try_read_lock()) {
// transaction operations can't run in parallel with loading
// state from the log (happens once per term change)
vlog(
Expand Down