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

Revert "txn: update abort_old_txes to use locks" #11474

Merged
merged 1 commit into from
Jun 16, 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 4 additions & 11 deletions src/v/kafka/server/group.cc
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ group::group(
kafka::group_id id,
group_state s,
config::configuration& conf,
ss::lw_shared_ptr<attached_partition> p,
ss::lw_shared_ptr<cluster::partition> partition,
model::term_id term,
ss::sharded<cluster::tx_gateway_frontend>& tx_frontend,
ss::sharded<features::feature_table>& feature_table,
Expand All @@ -62,8 +62,7 @@ group::group(
, _num_members_joining(0)
, _new_member_added(false)
, _conf(conf)
, _p(p)
, _partition(p != nullptr ? p->partition : nullptr)
, _partition(std::move(partition))
, _probe(_members, _static_members, _offsets)
, _ctxlog(klog, *this)
, _ctx_txlog(cluster::txlog, *this)
Expand All @@ -85,7 +84,7 @@ group::group(
kafka::group_id id,
group_metadata_value& md,
config::configuration& conf,
ss::lw_shared_ptr<attached_partition> p,
ss::lw_shared_ptr<cluster::partition> partition,
model::term_id term,
ss::sharded<cluster::tx_gateway_frontend>& tx_frontend,
ss::sharded<features::feature_table>& feature_table,
Expand All @@ -104,8 +103,7 @@ group::group(
, _leader(md.leader)
, _new_member_added(false)
, _conf(conf)
, _p(p)
, _partition(p->partition)
, _partition(std::move(partition))
, _probe(_members, _static_members, _offsets)
, _ctxlog(klog, *this)
, _ctx_txlog(cluster::txlog, *this)
Expand Down Expand Up @@ -1667,9 +1665,6 @@ void group::fail_offset_commit(
}

void group::reset_tx_state(model::term_id term) {
// must be invoked under catchup_lock.hold_write_lock()
// all other tx methods should use catchup_lock.hold_read_lock()
// to avoid modifying the state of the executing tx methods
_term = term;
_volatile_txs.clear();
_prepared_txs.clear();
Expand Down Expand Up @@ -3234,8 +3229,6 @@ void group::maybe_rearm_timer() {
}

ss::future<> group::do_abort_old_txes() {
auto units = co_await _p->catchup_lock.hold_read_lock();

std::vector<model::producer_identity> pids;
for (auto& [id, _] : _prepared_txs) {
pids.push_back(id);
Expand Down
18 changes: 2 additions & 16 deletions src/v/kafka/server/group.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,19 +50,6 @@ struct configuration;
namespace kafka {
struct group_log_group_metadata;

struct attached_partition {
bool loading;
ssx::semaphore sem{1, "k/group-mgr"};
ss::abort_source as;
ss::lw_shared_ptr<cluster::partition> partition;
ss::basic_rwlock<> catchup_lock;
model::term_id term{-1};

explicit attached_partition(ss::lw_shared_ptr<cluster::partition> p)
: loading(true)
, partition(std::move(p)) {}
};

/**
* \defgroup kafka-groups Kafka group membership API
*
Expand Down Expand Up @@ -215,7 +202,7 @@ class group final : public ss::enable_lw_shared_from_this<group> {
kafka::group_id id,
group_state s,
config::configuration& conf,
ss::lw_shared_ptr<attached_partition>,
ss::lw_shared_ptr<cluster::partition> partition,
model::term_id,
ss::sharded<cluster::tx_gateway_frontend>& tx_frontend,
ss::sharded<features::feature_table>&,
Expand All @@ -227,7 +214,7 @@ class group final : public ss::enable_lw_shared_from_this<group> {
kafka::group_id id,
group_metadata_value& md,
config::configuration& conf,
ss::lw_shared_ptr<attached_partition>,
ss::lw_shared_ptr<cluster::partition> partition,
model::term_id,
ss::sharded<cluster::tx_gateway_frontend>& tx_frontend,
ss::sharded<features::feature_table>&,
Expand Down Expand Up @@ -929,7 +916,6 @@ class group final : public ss::enable_lw_shared_from_this<group> {
ss::timer<clock_type> _join_timer;
bool _new_member_added;
config::configuration& _conf;
ss::lw_shared_ptr<attached_partition> _p;
ss::lw_shared_ptr<cluster::partition> _partition;
absl::node_hash_map<
model::topic_partition,
Expand Down
10 changes: 5 additions & 5 deletions src/v/kafka/server/group_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -723,7 +723,7 @@ ss::future<> group_manager::do_recover_group(
group_id,
group_stm.get_metadata(),
_conf,
p,
p->partition,
term,
_tx_frontend,
_feature_table,
Expand Down Expand Up @@ -918,7 +918,7 @@ group::join_group_stages group_manager::join_group(join_group_request&& r) {
return group::join_group_stages(
make_join_error(r.data.member_id, error_code::not_coordinator));
}
auto p = it->second;
auto p = it->second->partition;
group = ss::make_lw_shared<kafka::group>(
r.data.group_id,
group_state::empty,
Expand Down Expand Up @@ -1071,7 +1071,7 @@ group_manager::txn_offset_commit(txn_offset_commit_request&& r) {
r.data.group_id,
group_state::empty,
_conf,
p,
p->partition,
p->term,
_tx_frontend,
_feature_table,
Expand Down Expand Up @@ -1157,7 +1157,7 @@ group_manager::begin_tx(cluster::begin_group_tx_request&& r) {
r.group_id,
group_state::empty,
_conf,
p,
p->partition,
p->term,
_tx_frontend,
_feature_table,
Expand Down Expand Up @@ -1265,7 +1265,7 @@ group_manager::offset_commit(offset_commit_request&& r) {
r.data.group_id,
group_state::empty,
_conf,
p,
p->partition,
p->term,
_tx_frontend,
_feature_table,
Expand Down
13 changes: 13 additions & 0 deletions src/v/kafka/server/group_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,19 @@ class group_manager {
void detach_partition(const model::ntp&);
ss::future<> do_detach_partition(model::ntp);

struct attached_partition {
bool loading;
ssx::semaphore sem{1, "k/group-mgr"};
ss::abort_source as;
ss::lw_shared_ptr<cluster::partition> partition;
ss::basic_rwlock<> catchup_lock;
model::term_id term{-1};

explicit attached_partition(ss::lw_shared_ptr<cluster::partition> p)
: loading(true)
, partition(std::move(p)) {}
};

cluster::notification_id_type _leader_notify_handle;
cluster::notification_id_type _topic_table_notify_handle;

Expand Down