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.1.x] c/rm_stm: fixed returning incorrect max_collectible_offset #12190

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
16 changes: 14 additions & 2 deletions src/v/cluster/rm_stm.h
Original file line number Diff line number Diff line change
Expand Up @@ -215,13 +215,25 @@ class rm_stm final : public persisted_stm {
model::producer_identity, model::tx_seq, model::timeout_clock::duration);
ss::future<tx_errc> abort_tx(
model::producer_identity, model::tx_seq, model::timeout_clock::duration);

/**
* Returns the next after the last one decided. If there are no ongoing
* transactions this will return next offset to be applied to the the stm.
*/
model::offset last_stable_offset();
ss::future<fragmented_vector<rm_stm::tx_range>>
aborted_transactions(model::offset, model::offset);

model::offset max_collectible_offset() override {
return last_stable_offset();
const auto lso = last_stable_offset();
if (lso < model::offset{0}) {
return model::offset{};
}
/**
* Since the LSO may be equal to `_next` we must return offset which has
* already been decided and applied hence we subtract one from the last
* stable offset.
*/
return model::prev_offset(lso);
}

storage::stm_type type() override {
Expand Down