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

k/group: do not replicate empty offsets commit batch #22797

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
33 changes: 18 additions & 15 deletions src/v/kafka/server/group.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2997,22 +2997,25 @@ group::do_commit(kafka::group_id group_id, model::producer_identity pid) {

model::record_batch_reader::data_t batches;
batches.reserve(2);
// if pending offsets are empty, (there was no store_txn_offsets call, do
// not replicate the offsets update batch)
if (!ongoing_tx.offsets.empty()) {
mmaslankaprv marked this conversation as resolved.
Show resolved Hide resolved
cluster::simple_batch_builder store_offset_builder(
model::record_batch_type::raft_data, model::offset(0));
for (const auto& [tp, pending_offset] : ongoing_tx.offsets) {
update_store_offset_builder(
store_offset_builder,
tp.topic,
tp.partition,
pending_offset.offset_metadata.offset,
kafka::leader_epoch(pending_offset.offset_metadata.leader_epoch),
pending_offset.offset_metadata.metadata.value_or(""),
model::timestamp::now(),
std::nullopt);
}

cluster::simple_batch_builder store_offset_builder(
model::record_batch_type::raft_data, model::offset(0));
for (const auto& [tp, pending_offset] : ongoing_tx.offsets) {
update_store_offset_builder(
store_offset_builder,
tp.topic,
tp.partition,
pending_offset.offset_metadata.offset,
kafka::leader_epoch(pending_offset.offset_metadata.leader_epoch),
pending_offset.offset_metadata.metadata.value_or(""),
model::timestamp::now(),
std::nullopt);
}

batches.push_back(std::move(store_offset_builder).build());
batches.push_back(std::move(store_offset_builder).build());
}

group_tx::commit_metadata commit_tx;
commit_tx.group_id = group_id;
Expand Down