Skip to content

Commit

Permalink
rm_stm: make request validation stronger
Browse files Browse the repository at this point in the history
  • Loading branch information
rystsov committed Jun 18, 2022
1 parent 188de3f commit f147823
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/v/cluster/rm_stm.cc
Original file line number Diff line number Diff line change
Expand Up @@ -768,7 +768,7 @@ ss::future<result<raft::replicate_result>> rm_stm::do_replicate(
return replicate_tx(bid, std::move(b));
})
.finally([u = std::move(unit)] {});
} else if (bid.has_idempotent() && bid.first_seq <= bid.last_seq) {
} else if (bid.has_idempotent()) {
request_id rid{.pid = bid.pid, .seq = bid.first_seq};
return with_request_lock(
rid,
Expand Down Expand Up @@ -1063,6 +1063,16 @@ ss::future<result<raft::replicate_result>> rm_stm::replicate_seq(
}
auto synced_term = _insync_term;

if (bid.first_seq > bid.last_seq) {
vlog(
clusterlog.warn,
"first_seq={} of the batch should be less or equal to last_seq={}",
bid.first_seq,
bid.last_seq);
outcome->set_value();
co_return errc::generic_tx_error;
}

auto cached_offset = known_seq(bid);
if (cached_offset) {
if (cached_offset.value() < model::offset{0}) {
Expand Down

0 comments on commit f147823

Please sign in to comment.