Skip to content

storage: move call to transactional_stm_type() out of noexcept c-tor#30581

Merged
WillemKauf merged 2 commits into
redpanda-data:devfrom
WillemKauf:abort_fix
May 22, 2026
Merged

storage: move call to transactional_stm_type() out of noexcept c-tor#30581
WillemKauf merged 2 commits into
redpanda-data:devfrom
WillemKauf:abort_fix

Conversation

@WillemKauf
Copy link
Copy Markdown
Contributor

This function call, transactional_stm_type(), used to just check the _tx_stmstatus - however, now it performs a check_status() call, which will throw a gate_closed_exception() if the _status is status::shutting_down: f935a80.

Because of this change, when this function throws (i.e. during shutdown), the previously truly noexcept constructor now causes an abort of the program.

Move the call to outside of the noexcept constructor to prevent this race from terminating the program.

Backports Required

  • none - not a bug fix
  • none - this is a backport
  • none - issue does not exist in previous branches
  • none - papercut/not impactful enough to backport
  • v26.1.x
  • v25.3.x
  • v25.2.x

Release Notes

  • none

…c-tor

This function call, `transactional_stm_type()`, used to just check the `_tx_stm`
status - however, now it performs a `check_status()` call, which will throw
a `gate_closed_exception()` if the `_status` is `status::shutting_down`: f935a80.

Because of this change, when this function throws (i.e. during shutdown),
the previously truly `noexcept` constructor now causes an abort of the program.

Move the call to outside of the `noexcept` constructor to prevent this race
from terminating the program.
Because why are we doing this?
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR prevents shutdown-time exceptions from causing a fatal std::terminate() by removing a potentially-throwing stm_hookset::transactional_stm_type() call from a noexcept tx_reducer constructor, and instead computing/passing the value at the call site.

Changes:

  • Precompute transactional_stm_type() in build_compaction_index() and pass it into tx_reducer.
  • Update tx_reducer to accept the precomputed std::optional<storage::stm_type> and stop calling into stm_hookset from its constructor.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/v/storage/segment_utils.cc Computes transactional_stm_type() before constructing tx_reducer, avoiding a throw inside the reducer constructor.
src/v/storage/compaction_reducers.h Updates tx_reducer constructor signature to accept the precomputed transactional STM type and removes the throwing call from the initializer list.

@WillemKauf WillemKauf enabled auto-merge May 21, 2026 23:35
@WillemKauf
Copy link
Copy Markdown
Contributor Author

/ci-repeat 1
skip-redpanda-build
skip-units

@WillemKauf WillemKauf merged commit 4b37134 into redpanda-data:dev May 22, 2026
24 checks passed
@vbotbuildovich
Copy link
Copy Markdown
Collaborator

/backport v26.1.x

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants