You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iggy.apache.org by hg...@apache.org on 2026/10/07 21:01:47 UTC
(iggy) branch perf/task-per-partition updated (c1ce09a39 -> 12d134e8e)
This is an automated email from the ASF dual-hosted git repository.
hubcio pushed a change to branch perf/task-per-partition
in repository https://gitbox.apache.org/repos/asf/iggy.git
from c1ce09a39 fix(sdk): recognize partition history changes in Swift
new e433f5451 fix(partitions): rebuild header indexes after truncation
new bd92da9f9 fix(partitions): resume shutdown after interrupted file jobs
new ec47f67fc fix(sdk): recognize partition history changes across clients
new 12d134e8e docs(partitions): align comments with file lanes and commit walks
The 4 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
core/consensus/src/impls.rs | 2 +-
core/metadata/src/stm/result.rs | 4 ++
core/partitions/src/iggy_partition.rs | 39 +++++++++++-
core/partitions/src/journal.rs | 74 +++++++++++++++++-----
core/partitions/src/types.rs | 2 +-
core/shard/src/lib.rs | 13 ++--
core/shard/src/router.rs | 3 +-
core/simulator/src/lib.rs | 2 +-
core/simulator/src/workload/invariants.rs | 2 +-
foreign/go/errors/errors.yaml | 4 ++
foreign/go/errors/errors_gen.go | 17 +++++
foreign/go/errors/errors_test.go | 6 ++
.../org/apache/iggy/exception/IggyErrorCode.java | 1 +
.../apache/iggy/exception/IggyErrorCodeTest.java | 1 +
foreign/node/src/wire/error.code.test.ts | 4 ++
foreign/node/src/wire/error.code.ts | 1 +
16 files changed, 143 insertions(+), 32 deletions(-)
(iggy) 04/04: docs(partitions): align comments with file lanes and commit walks
Posted by hg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
hubcio pushed a commit to branch perf/task-per-partition
in repository https://gitbox.apache.org/repos/asf/iggy.git
commit 12d134e8e72b845abcea144e79724341e0cb3b62
Author: Hubert Gruszecki <h....@gmail.com>
AuthorDate: Wed Oct 7 23:00:51 2026 +0200
docs(partitions): align comments with file lanes and commit walks
---
core/consensus/src/impls.rs | 2 +-
core/partitions/src/types.rs | 2 +-
core/shard/src/lib.rs | 13 ++++---------
core/simulator/src/lib.rs | 2 +-
core/simulator/src/workload/invariants.rs | 2 +-
5 files changed, 8 insertions(+), 13 deletions(-)
diff --git a/core/consensus/src/impls.rs b/core/consensus/src/impls.rs
index b93ec2195..61d4d6dbc 100644
--- a/core/consensus/src/impls.rs
+++ b/core/consensus/src/impls.rs
@@ -2171,7 +2171,7 @@ impl<B: MessageBus, P: Pipeline<Entry = PipelineEntry>> VsrConsensus<B, P> {
///
/// Stops the timer on an empty pipeline; otherwise restarts it so it times
/// the current oldest entry from now. Exposed for the plane-side drains that
- /// pop through [`Pipeline`] directly (`drain_committable_prefix`) rather than
+ /// pop through [`Pipeline`] directly rather than
/// through [`Self::pop_committed_prepare`].
pub fn sync_prepare_timeout(&self) {
let empty = self.pipeline.borrow().is_empty();
diff --git a/core/partitions/src/types.rs b/core/partitions/src/types.rs
index 9d55f2ee8..c1f578676 100644
--- a/core/partitions/src/types.rs
+++ b/core/partitions/src/types.rs
@@ -23,7 +23,7 @@ use std::sync::Arc;
/// A local commit that failed for an op the cluster had already committed.
///
-/// The replica is divergent from here on: `drain_committable_prefix` popped
+/// The replica is divergent from here on: the commit walk popped
/// the op, its `commit_min` never advanced, and the next
/// `advance_commit_min` would assert on the gap. Continuing would either
/// serve a prefix the cluster has moved past or panic somewhere less
diff --git a/core/shard/src/lib.rs b/core/shard/src/lib.rs
index 44b1aebdf..e9c223cb5 100644
--- a/core/shard/src/lib.rs
+++ b/core/shard/src/lib.rs
@@ -6035,9 +6035,6 @@ where
// only, while `commit_messages` evicts up to `commit_max` (the cluster
// frontier), so a primary-elect with an apply backlog reads `None` for
// ops it holds in the repair ring and parks on a hole that is not one.
- // One pass also because `header_by_op` is a linear scan and this window
- // is the apply backlog, not the `prepare_queue_max` span the merge
- // bounds -- probing per op is quadratic.
let missing = {
let journal = partition.log.journal();
let window = journal
@@ -10832,16 +10829,14 @@ const PARTITION_REPAIRS_INFLIGHT_MAX: usize = 8;
/// Commit walks the partition tick sweep will RUN per pass.
///
/// Same correlated-fan-out argument as the repair arm, and the walk is the
-/// costlier half: `commit_journal` reaches `commit_messages`, which flushes a
-/// segment and synchronizes it under `durability=persisted`.
+/// costlier half: `commit_journal` applies committed state and schedules
+/// segment persistence.
///
/// The two caps together are what bound the tick: this one bounds how many
/// groups a sweep walks, [`partitions::COMMIT_WALK_OPS_MAX`] bounds how far
/// each walk goes (for every caller of `commit_journal`, not just this one),
-/// and the product is the sweep's worst case. Deliberately NOT the
-/// superblock pre-pass's number: that one runs its fan-out CONCURRENTLY under
-/// `join_all` and drains every group in the same body, while these walks are
-/// serial and what is over budget waits for the next tick.
+/// and the product is the sweep's worst case. File jobs are bounded separately
+/// by the partition I/O lane; commit walks over budget wait for the next tick.
///
/// Capping cannot starve a partition: the walk carries no debounce counter and
/// clears its own predicate (a walk either advances `commit_min` or fences the
diff --git a/core/simulator/src/lib.rs b/core/simulator/src/lib.rs
index e3bb25a8d..cb3980bda 100644
--- a/core/simulator/src/lib.rs
+++ b/core/simulator/src/lib.rs
@@ -139,7 +139,7 @@ pub(crate) struct PartitionConsensusState {
/// A pipeline head the commit walk is holding on: covered by the commit frontier,
/// but not the op the state machine is next owed.
///
-/// What `drain_committable_prefix` / `peek_committable_head` refuse to drain. Two
+/// What `peek_committable_head` refuses to drain. Two
/// different faults share that refusal and need different thresholds, so
/// [`CommitPrefixHole::kind`] keeps them apart.
#[derive(Debug, Clone, Copy)]
diff --git a/core/simulator/src/workload/invariants.rs b/core/simulator/src/workload/invariants.rs
index a51103e97..31f949e79 100644
--- a/core/simulator/src/workload/invariants.rs
+++ b/core/simulator/src/workload/invariants.rs
@@ -211,7 +211,7 @@ impl Invariants {
/// Catch a commit walk permanently held below a committable pipeline head.
///
- /// The state `drain_committable_prefix` and `peek_committable_head` refuse to
+ /// The state `peek_committable_head` refuses to
/// drain. Two faults share that refusal and they are not the same wait, so they
/// are counted apart (see [`CommitHoldKind`]):
///
(iggy) 03/04: fix(sdk): recognize partition history changes across clients
Posted by hg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
hubcio pushed a commit to branch perf/task-per-partition
in repository https://gitbox.apache.org/repos/asf/iggy.git
commit ec47f67fcce46a5074a2ba903e2088dcc20f10c1
Author: Hubert Gruszecki <h....@gmail.com>
AuthorDate: Wed Oct 7 23:00:32 2026 +0200
fix(sdk): recognize partition history changes across clients
Go, Node and Java did not recognize the history-change error returned
by stale DeleteSegments requests. Add code 3014 to their existing
tables and pin its metadata result mapping with regression tests.
---
core/metadata/src/stm/result.rs | 4 ++++
foreign/go/errors/errors.yaml | 4 ++++
foreign/go/errors/errors_gen.go | 17 +++++++++++++++++
foreign/go/errors/errors_test.go | 6 ++++++
.../java/org/apache/iggy/exception/IggyErrorCode.java | 1 +
.../org/apache/iggy/exception/IggyErrorCodeTest.java | 1 +
foreign/node/src/wire/error.code.test.ts | 4 ++++
foreign/node/src/wire/error.code.ts | 1 +
8 files changed, 38 insertions(+)
diff --git a/core/metadata/src/stm/result.rs b/core/metadata/src/stm/result.rs
index 5d4b49a12..2f75c85a2 100644
--- a/core/metadata/src/stm/result.rs
+++ b/core/metadata/src/stm/result.rs
@@ -682,6 +682,10 @@ mod tests {
partition_id_space_exhausted,
IggyError::TooManyPartitions.as_code(),
);
+ assert_eq!(
+ u32::from(TruncatePartitionResult::HistoryChanged),
+ IggyError::PartitionHistoryChanged.as_code(),
+ );
// Unauthorized (41) - the global in-apply RBAC denial code.
assert_eq!(UNAUTHORIZED_CODE, IggyError::Unauthorized.as_code());
diff --git a/foreign/go/errors/errors.yaml b/foreign/go/errors/errors.yaml
index 7a6b588d2..5fd40989e 100644
--- a/foreign/go/errors/errors.yaml
+++ b/foreign/go/errors/errors.yaml
@@ -791,6 +791,10 @@
code: 3013
format: "partition id space exhausted for this topic"
fields: []
+- name: PartitionHistoryChanged
+ code: 3014
+ format: "partition history changed after the request was resolved"
+ fields: []
- name: SegmentNotFound
code: 4000
format: "segment not found"
diff --git a/foreign/go/errors/errors_gen.go b/foreign/go/errors/errors_gen.go
index ce151e65e..a9613e494 100644
--- a/foreign/go/errors/errors_gen.go
+++ b/foreign/go/errors/errors_gen.go
@@ -1628,6 +1628,17 @@ func (e PartitionIdSpaceExhausted) Is(target error) bool {
return ok
}
+type PartitionHistoryChanged struct{}
+
+func (e PartitionHistoryChanged) Error() string {
+ return "partition history changed after the request was resolved"
+}
+func (e PartitionHistoryChanged) Code() Code { return 3014 }
+func (e PartitionHistoryChanged) Is(target error) bool {
+ _, ok := target.(PartitionHistoryChanged)
+ return ok
+}
+
type SegmentNotFound struct{}
func (e SegmentNotFound) Error() string { return "segment not found" }
@@ -2844,6 +2855,7 @@ var (
ErrCannotOpenConsumerOffsetsFile = CannotOpenConsumerOffsetsFile{}
ErrTooManyConsumerOffsets = TooManyConsumerOffsets{}
ErrPartitionIdSpaceExhausted = PartitionIdSpaceExhausted{}
+ ErrPartitionHistoryChanged = PartitionHistoryChanged{}
ErrSegmentNotFound = SegmentNotFound{}
ErrSegmentClosed = SegmentClosed{}
ErrInvalidSegmentSize = InvalidSegmentSize{}
@@ -3092,6 +3104,7 @@ const (
CannotOpenConsumerOffsetsFileCode Code = 3023
TooManyConsumerOffsetsCode Code = 3024
PartitionIdSpaceExhaustedCode Code = 3013
+ PartitionHistoryChangedCode Code = 3014
SegmentNotFoundCode Code = 4000
SegmentClosedCode Code = 4001
InvalidSegmentSizeCode Code = 4002
@@ -3483,6 +3496,8 @@ func (c Code) String() string {
return "TooManyConsumerOffsets"
case PartitionIdSpaceExhaustedCode:
return "PartitionIdSpaceExhausted"
+ case PartitionHistoryChangedCode:
+ return "PartitionHistoryChanged"
case SegmentNotFoundCode:
return "SegmentNotFound"
case SegmentClosedCode:
@@ -3976,6 +3991,8 @@ func FromCode(code Code) IggyError {
return ErrTooManyConsumerOffsets
case PartitionIdSpaceExhaustedCode:
return ErrPartitionIdSpaceExhausted
+ case PartitionHistoryChangedCode:
+ return ErrPartitionHistoryChanged
case SegmentNotFoundCode:
return ErrSegmentNotFound
case SegmentClosedCode:
diff --git a/foreign/go/errors/errors_test.go b/foreign/go/errors/errors_test.go
index 70a33c4ed..8648a57b6 100644
--- a/foreign/go/errors/errors_test.go
+++ b/foreign/go/errors/errors_test.go
@@ -70,6 +70,12 @@ func TestIggyError_ConsensusErrors(t *testing.T) {
code: RequestTooOldCode,
message: "request is below the deduplication window; outcome unknown, resending may duplicate the write",
},
+ {
+ err: PartitionHistoryChanged{},
+ sentinel: ErrPartitionHistoryChanged,
+ code: Code(3014),
+ message: "partition history changed after the request was resolved",
+ },
{
err: ConsumerGroupPartitionNotOwned{ClientId: 4, PartitionId: 9},
sentinel: ErrConsumerGroupPartitionNotOwned,
diff --git a/foreign/java/java-sdk/src/main/java/org/apache/iggy/exception/IggyErrorCode.java b/foreign/java/java-sdk/src/main/java/org/apache/iggy/exception/IggyErrorCode.java
index 752402570..e3c290e65 100644
--- a/foreign/java/java-sdk/src/main/java/org/apache/iggy/exception/IggyErrorCode.java
+++ b/foreign/java/java-sdk/src/main/java/org/apache/iggy/exception/IggyErrorCode.java
@@ -100,6 +100,7 @@ public enum IggyErrorCode {
// Partition errors
PARTITION_NOT_FOUND(3007),
PARTITION_ID_SPACE_EXHAUSTED(3013),
+ PARTITION_HISTORY_CHANGED(3014),
// Consumer offset errors
TOO_MANY_CONSUMER_OFFSETS(3024),
diff --git a/foreign/java/java-sdk/src/test/java/org/apache/iggy/exception/IggyErrorCodeTest.java b/foreign/java/java-sdk/src/test/java/org/apache/iggy/exception/IggyErrorCodeTest.java
index 0aea979fb..30c0609d3 100644
--- a/foreign/java/java-sdk/src/test/java/org/apache/iggy/exception/IggyErrorCodeTest.java
+++ b/foreign/java/java-sdk/src/test/java/org/apache/iggy/exception/IggyErrorCodeTest.java
@@ -217,6 +217,7 @@ class IggyErrorCodeTest {
// Partition errors
"3007, PARTITION_NOT_FOUND",
"3013, PARTITION_ID_SPACE_EXHAUSTED",
+ "3014, PARTITION_HISTORY_CHANGED",
"3024, TOO_MANY_CONSUMER_OFFSETS",
// Segment errors
diff --git a/foreign/node/src/wire/error.code.test.ts b/foreign/node/src/wire/error.code.test.ts
index 8ea8123e0..30c260690 100644
--- a/foreign/node/src/wire/error.code.test.ts
+++ b/foreign/node/src/wire/error.code.test.ts
@@ -34,6 +34,10 @@ it('translates the consumer-offset capacity error', () => {
assert.equal(translateErrorCode(3024), 'Consumer offset limit reached for partition, raise [partition] consumer_offsets_max');
});
+it('translates a partition history change', () => {
+ assert.equal(translateErrorCode(3014), 'Partition history changed after the request was resolved');
+});
+
it('translates the consumer-group error range', () => {
assert.equal(
translateErrorCode(5000),
diff --git a/foreign/node/src/wire/error.code.ts b/foreign/node/src/wire/error.code.ts
index d05fc9d8e..5fd61dcfc 100644
--- a/foreign/node/src/wire/error.code.ts
+++ b/foreign/node/src/wire/error.code.ts
@@ -169,6 +169,7 @@ export const translateErrorCode = (code: number): string => {
case '3023': return "Cannot open consumer offsets file for path: {0}";
case '3024': return "Consumer offset limit reached for partition, raise [partition] consumer_offsets_max";
case '3013': return "Partition id space exhausted for this topic";
+ case '3014': return "Partition history changed after the request was resolved";
// MESSAGE
case '4000': return "Segment not found";
(iggy) 01/04: fix(partitions): rebuild header indexes after truncation
Posted by hg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
hubcio pushed a commit to branch perf/task-per-partition
in repository https://gitbox.apache.org/repos/asf/iggy.git
commit e433f54516c9280d396bf919d498d4f1c6710b5a
Author: Hubert Gruszecki <h....@gmail.com>
AuthorDate: Wed Oct 7 22:59:47 2026 +0200
fix(partitions): rebuild header indexes after truncation
Truncation retained stale header positions and could select the wrong
checksum during repair. Clear the index before replaying retained
entries and cover out-of-order repair plus duplicate operations.
---
core/partitions/src/journal.rs | 74 ++++++++++++++++++++++++++++++++----------
1 file changed, 57 insertions(+), 17 deletions(-)
diff --git a/core/partitions/src/journal.rs b/core/partitions/src/journal.rs
index a2b4a6232..d8f741b45 100644
--- a/core/partitions/src/journal.rs
+++ b/core/partitions/src/journal.rs
@@ -881,14 +881,8 @@ where
/// Presence and message-carrying shape of the repair window `(floor, to_op]`
/// in ONE pass over the header vec.
///
- /// [`Self::header_by_op`] is a linear scan with no index, so asking it
- /// op-by-op over a window is O(window x headers): on the floor-refusal path
- /// the replica is gap-stopped, so nothing evicts and the header vec grows
- /// with the live tail, and even a 4096-op window over ~100k resident
- /// headers is on the order of 4e8 comparisons -- synchronous, on the shard
- /// pump, per repair round. Long enough to miss heartbeat and view-change
- /// deadlines for every group on the core and turn one rejoin into an
- /// election storm.
+ /// Work and scratch space are bounded by resident headers, even when the
+ /// requested op window is much larger than the local journal.
///
/// The evicted ring is deliberately NOT consulted, matching the op-by-op
/// form: consulting it would change the floor-refusal verdict.
@@ -946,8 +940,7 @@ where
/// can recover from a log alone: a prepare records the primary's commit point
/// at send time, so the true point may be one higher.
///
- /// Exists so callers do not walk `1..=head` through [`Self::header_by_op`],
- /// which is a linear scan per op and so quadratic in the head.
+ /// Scans resident headers without probing every op up to the log head.
pub fn max_commit_watermark(&self) -> u64 {
let headers = unsafe { &*self.headers.get() };
headers
@@ -976,11 +969,6 @@ where
// streaming) with repaired window ops, so append order is no longer
// op-ascending and a positional sequential scan would break at the
// first interleave boundary forever.
- //
- // ONE pass over the headers, like `repaired_window_shape`, not a
- // `header_by_op` probe per op: that probe is itself a linear scan, so
- // probing walked the window against the whole vec, and the walk this
- // feeds runs per group per tick over a rejoin's entire backlog.
if from_op > commit_max {
return Vec::new();
}
@@ -1009,8 +997,7 @@ where
}
#[allow(clippy::cast_possible_truncation)]
let slot = (header.op - from_op) as usize;
- // First writer wins, matching the `header_by_op` probe this
- // replaces (`find` returns the earliest match).
+ // Keep the first resident occurrence, matching `header_by_op`.
slots[slot].get_or_insert(*header);
}
// Stops at the first hole: a replication gap must not be skipped, or
@@ -1173,6 +1160,7 @@ impl Journal for PartitionJournal<PartitionJournalMemStorage> {
};
{
unsafe { &mut *self.headers.get() }.clear();
+ self.first_header_by_op.borrow_mut().clear();
unsafe { &mut *self.op_to_storage_offset.get() }.clear();
unsafe { &mut *self.offset_to_op.get() }.clear();
unsafe { &mut *self.timestamp_to_op.get() }.clear();
@@ -1556,6 +1544,58 @@ mod tests {
assert_eq!(journal.last_op(), Some(4));
}
+ #[compio::test]
+ async fn given_reordered_duplicates_when_truncating_should_index_retained_headers() {
+ let journal = PartitionJournal::<PartitionJournalMemStorage>::default();
+ for (op, checksum) in [(3, 30), (1, 10), (4, 40), (2, 20), (1, 11), (2, 21)] {
+ let entry = build_prepare(op, HEADER_SIZE).transmute_header(
+ |mut old, header: &mut PrepareHeader| {
+ old.checksum = checksum;
+ *header = old;
+ },
+ );
+ journal.append(entry.into_frozen()).await.unwrap();
+ }
+
+ assert_eq!(journal.truncate_from(3).await.unwrap(), 2);
+ for (op, checksum) in [(1, 10), (2, 20)] {
+ let header = journal.header_by_op(op).expect("retained header");
+ assert_eq!(header.op, op);
+ assert_eq!(header.checksum, checksum, "the first duplicate must win");
+ assert!(journal.entry(&header).await.is_some());
+ }
+ for op in [3, 4] {
+ assert!(journal.header_by_op(op).is_none(), "op {op} was removed");
+ }
+ }
+
+ #[compio::test]
+ async fn given_truncated_journal_when_repairing_out_of_order_should_keep_frontier_checksum() {
+ let journal = PartitionJournal::<PartitionJournalMemStorage>::default();
+ for op in [1, 2, 3] {
+ journal
+ .append(build_prepare(op, HEADER_SIZE).into_frozen())
+ .await
+ .unwrap();
+ }
+ journal.truncate_from(2).await.unwrap();
+ for op in [3, 2] {
+ let entry = build_prepare(op, HEADER_SIZE).transmute_header(
+ |mut old, header: &mut PrepareHeader| {
+ old.checksum = u128::from(op);
+ *header = old;
+ },
+ );
+ journal.append(entry.into_frozen()).await.unwrap();
+ }
+
+ assert_eq!(
+ consensus::repaired_frontier_update(3, |op| journal.header_by_op(op)),
+ Some((3, 3)),
+ "repair must pair the frontier op with its own checksum"
+ );
+ }
+
#[compio::test]
async fn repaired_window_shape_rejects_unbounded_sparse_window_before_allocation() {
let journal = PartitionJournal::<PartitionJournalMemStorage>::default();
(iggy) 02/04: fix(partitions): resume shutdown after interrupted file jobs
Posted by hg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
hubcio pushed a commit to branch perf/task-per-partition
in repository https://gitbox.apache.org/repos/asf/iggy.git
commit bd92da9f94c445679d559a8c0ba2ba7187050166
Author: Hubert Gruszecki <h....@gmail.com>
AuthorDate: Wed Oct 7 23:00:13 2026 +0200
fix(partitions): resume shutdown after interrupted file jobs
An interrupted file job could leave its shutdown owner asleep until
the drain timed out. Notify the fenced owner without releasing its
held resources, and avoid rescanning owners while file jobs remain.
---
core/partitions/src/iggy_partition.rs | 39 ++++++++++++++++++++++++++++++++++-
core/shard/src/router.rs | 3 ++-
2 files changed, 40 insertions(+), 2 deletions(-)
diff --git a/core/partitions/src/iggy_partition.rs b/core/partitions/src/iggy_partition.rs
index 5dfb69540..ed6fdf809 100644
--- a/core/partitions/src/iggy_partition.rs
+++ b/core/partitions/src/iggy_partition.rs
@@ -1957,7 +1957,7 @@ where
if self.materialization_missing || !self.ensure_wal_view() {
return;
}
- // The shard's bounded pre-pass owns superblock I/O across partitions.
+ // The file lane must persist the superblock before WAL acks can advance.
if self.superblock.is_some() && self.consensus.needs_superblock_persist() {
return;
}
@@ -5848,6 +5848,7 @@ where
pub fn interrupt_io(&mut self, identity: crate::PartitionIoIdentity) {
if self.io_active.get() == Some(identity) {
self.fence_flush_failure();
+ self.notify_io();
}
}
@@ -20172,6 +20173,42 @@ mod tests {
assert_eq!(reply.status, IggyError::TransientNotAccepted.as_code());
}
+ #[compio::test]
+ async fn given_shutdown_waiting_for_io_when_interrupted_should_notify_and_keep_resources() {
+ let mut partition = partition_at_view(1, 1);
+ partition.set_superblock(Rc::new(RecordingSuperblock::default()), None);
+ let notifications = Rc::new(Cell::new(0));
+ let observed = Rc::clone(¬ifications);
+ partition.set_io_notifier(
+ Rc::new(move |_, _| observed.set(observed.get() + 1)),
+ crate::largest_legal_job_charge().unwrap(),
+ );
+ assert!(!partition.persist_superblock_if_needed().await);
+ let config = repair_config();
+ let crate::PartitionIoStep::Ready(plan) = partition.resume_io(&config).await else {
+ panic!("view persistence must be ready");
+ };
+ let captured = partition.capture_io(plan, &config).unwrap().unwrap();
+
+ partition.begin_shutdown_io();
+ assert!(matches!(
+ partition.resume_io(&config).await,
+ crate::PartitionIoStep::Pending
+ ));
+ assert!(!partition.shutdown_io_complete());
+ notifications.set(0);
+
+ captured.quiescence.interrupt();
+ partition.interrupt_io(captured.identity);
+ assert!(notifications.get() > 0, "the shutdown owner must be ready");
+ partition.resume_io(&config).await;
+
+ assert!(partition.shutdown_io_complete());
+ assert_eq!(partition.io_active.get(), Some(captured.identity));
+ assert_eq!(captured.quiescence.get(), Some(captured.identity));
+ assert!(partition.superblock_lock.try_acquire().is_none());
+ }
+
#[compio::test]
async fn shutdown_flushes_committed_messages_with_an_unacknowledged_pipeline_tail() {
for (replica_count, store_offset) in [(3, false), (1, true), (3, true)] {
diff --git a/core/shard/src/router.rs b/core/shard/src/router.rs
index 969cdec2b..f2022596d 100644
--- a/core/shard/src/router.rs
+++ b/core/shard/src/router.rs
@@ -588,12 +588,13 @@ where
self.service_partition_io().await;
self.process_loopback(loopback).await;
let finished = !self.partition_io.has_ready()
+ && self.partition_io.outstanding() == 0
&& namespaces.iter().all(|namespace| {
partitions
.get_io_owner(namespace)
.is_none_or(|partition| partition.shutdown_io_complete())
});
- if finished && self.partition_io.outstanding() == 0 {
+ if finished {
break;
}
futures::select_biased! {