[v25.2.x] [CORE-14558] storage: prevent race between disk_log_appender and remove_prefix_full_segments() (MANUAL BACKPORT)#28563
Closed
WillemKauf wants to merge 6 commits intoredpanda-data:v25.2.xfrom
Conversation
Instead, log batch append errors in the `disk_log_appender` at `ERROR`. (cherry picked from commit f7ca2ec)
A useful sanity check to prevent any potential concurrency issues. (cherry picked from commit df9089a)
…ve()`...
...in `disk_log_impl`
Without any sort of safety guarantees around mutual exclusion
of these functions, we can easily end up with an assert failure like
```
ERROR 2025-11-13 15:50:46,593 [shard 0:main] assert - Assert failure: (src/v/storage/disk_log_impl.cc:2084) '!_closed' flush on closed log - {offsets: {start_offset:850, committed_offset:849, committed_offset_term:-9223372036854775808, dirty_offset:849, dirty_offset_term:-9223372036854775808}, is_closed: true, segments: [{size: 0, []}], config: {ntp: {test.log_builder/OOvVPTBb/0}, base_dir: /home/willem/.cache/bazel/_bazel_willem/6fc2d9663f4e6fbf4046ab3d95678674/sandbox/linux-sandbox/12837/execroot/_main/_tmp/efa90c48b51a675ce0846aa066568b84/test.dir_8IlPIe, overrides: nullptr, revision: 0, topic_revision: -9223372036854775808, remote_revision: 0}}
```
Due to the call to `flush()` in `truncate_prefix()`.
Wait for and break the `_segment_rewrite_lock()` in `disk_log_impl::close()`
and `remove()` to avoid this issue.
(cherry picked from commit 485b24d)
…x_full_segments()` We will be calling `remove_segment_permanently()` on what is potentially the active segment in `remove_prefix_full_segments()`. If there is a concurrent append occuring, we may get into a race with the `disk_log_appender` since we return the units in `lock_holder` (i.e the segment's write lock) while the future for `remove_segment_permanently()` is still unresolved. In this case, we need to obtain units from `_segments_rolling_lock` to prevent any concurrency issues, which manifest as either a thrown exception due to gate closure, or an inability to add batches to a closed `segment`. (cherry picked from commit e31ae0b)
For use in a non-seastar thread context. (cherry picked from commit a0ae962)
A test which validates potential races between `disk_log_appender`, a `truncate_prefix()` operation, and a `close()` operation in a concurrent context. Without the previous two commits, this test would occasionally demonstrate assert failures around operations on closed logs. (cherry picked from commit 799ff14)
WillemKauf
commented
Nov 14, 2025
Contributor
Author
|
This should be okay to merge at this point. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Manual backport of #28472.
cherry-pickconflict due to missing includes.Fixes #28546.
Backports Required
Release Notes
Bug Fixes