Skip to content

feat(partitions)!: fence ownership and history changes - #4456

Merged
hubcio merged 47 commits into
masterfrom
feat/ownership-and-history
Oct 12, 2026
Merged

hubcio merged 47 commits into
masterfrom
feat/ownership-and-history

Conversation

@hubcio

@hubcio hubcio commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Queued requests, detached polls and retries can outlive their
consumer-group assignment or partition incarnation. Changing metadata
alone does not fence those operations at partition apply or recovery.

Order owner installs, owner retirement and delete fences in partition
logs. Require applied partition evidence before completing handoffs
or destructive metadata lifecycles. Retain owner and fence evidence
and lifecycle intents through checkpoints, restart and state
transfer. A committed delete fence closes the partition incarnation
for good. Admission drains admitted work before the fence, and the
partition refuses later requests and repaired prepares.

A consumer group join commits the membership at once. The member
owns a partition only after that partition durably installs it as
the owner. Until then, a sync omits the partition, and group polls
and group offset calls for it fail with 5009.

Serve a group poll only to the owner that the partition installed.
If the replica lags behind the poller's assignment, the poll fails
with 58 and the client retries. If the installed owner is newer,
another client or unassigned, the poll fails with 5009 and the
client syncs again. A view change can leave owner installs unapplied
in the log. Until the partition applies them, group reads and group
offset writes fail with 58.

Reclaim deleted owner rows using replicated metadata evidence and
check the partition-set revision before finalizing sessions. Preserve
stable assignments and add an immutable fixed/mutable partition-resize
policy. Re-ack matching committed prepares without reapplying them.
Limit a topic to 2^20 live consumer groups, the bound of the owner
retirement catalog. Past it, group creation fails with
TooManyConsumerGroups (5010).

Carry captured context through Rust and foreign SDK operations and
retain request context across uncertain retries. Add position-based
offset commits and update local stored progress after successful
offset-store calls.

Accept an optional partition context on HTTP sends, in the shape
that offset stores use. Give raw requests a captured context. A raw
send without a partition id fails with FeatureUnavailable (5). Route
offset writes to the partition primary. Sync an empty group
assignment again on every poll.

Repair can journal batches out of operation order. Lower batches
then look persisted after a higher batch reaches disk. Restore
journal order before materialization and wait at operation gaps, so
that materialization does not drop those batches.

When a receiver installs transferred state, protect the acknowledged
prepares above its known commit. Gate acknowledgements on the
contiguous WAL admission frontier, and keep recovery for
unacknowledged bodies above WAL gaps. Accept complete local repair
prefixes and cancel obsolete transfer re-arms after catching up.

Let partitions without messages recover by state transfer. Offer an
empty chain at frontier 0. Refuse a repair that moves the commit
floor of a replica with no committed message over ops that it never
saw.

Fail boot on incomplete segment-directory listings before recovery
can remove unseen committed logs. Use the configured wedge timeout
for file jobs, where zero disables it. If a timed-out job belongs to
a tombstoned partition, stop the node. On a single-replica cluster,
finish the lifecycle of a partition that recovery fenced before it
mounted, so that a topic or group delete completes.

Consolidate superblock writes and request queue conditions while
preserving CREATE backoff behavior and lazy offset checks. Remove
unreachable dispatcher branches and redundant sampler/pipeline state.
Encode the poll head in one place.

Fixes #4292

BREAKING CHANGE: affects storage, replica-to-replica communication,
and SDK-to-server communication.

Storage: require the IGGY-OWNERSHIP-HISTORY-4 marker, metadata
snapshots v11 and ICO1 partition checkpoint/state-transfer data v7.
Reject incompatible data directories before mutation. This change
provides no in-place migration.

Replica-to-replica: prepare headers carry the partition incarnation,
offset prepares carry owner generations, and replicated control
operations and payloads change. Mixed-version replicas are
unsupported.

SDK-to-server: binary request/reply context fields, HTTP send bodies,
and poll, routing and topic response layouts change. The partition
context is 24 bytes: incarnation, owner generation and metadata op.
The new error codes are HistoryUnavailable (87), LifecycleBusy (88)
and TooManyConsumerGroups (5010). A join returns before the member
owns its partitions. Context-bearing SDK APIs also change. Upgrade
servers and compatible SDKs together.

@github-actions github-actions Bot added the S-waiting-on-review PR is waiting on a reviewer label Oct 8, 2026
@codecov

codecov Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.15444% with 248 lines in your changes missing coverage. Please review.
✅ Project coverage is 88.16%. Comparing base (1cd19ce) to head (c90b78c).

Files with missing lines Patch % Lines
core/metadata/src/stm/lifecycle.rs 94.17% 55 Missing and 18 partials ⚠️
core/metadata/src/stm/consumer_group.rs 96.02% 22 Missing and 6 partials ⚠️
core/partitions/src/state_transfer.rs 91.69% 12 Missing and 15 partials ⚠️
core/sdk/src/clients/consumer.rs 95.45% 21 Missing and 2 partials ⚠️
core/sdk/src/http/http_client.rs 92.89% 7 Missing and 5 partials ⚠️
core/metadata/src/stm/stream.rs 97.06% 7 Missing and 3 partials ⚠️
core/metadata/src/impls/metadata.rs 96.65% 8 Missing and 1 partial ⚠️
...equests/partitions/retire_consumer_group_owners.rs 92.30% 6 Missing and 1 partial ⚠️
core/common/src/traits/binary_transport.rs 96.19% 7 Missing ⚠️
core/common/src/http/messages/send_messages.rs 88.67% 3 Missing and 3 partials ⚠️
... and 21 more
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #4456      +/-   ##
============================================
- Coverage     88.45%   88.16%   -0.30%     
- Complexity     1607     1728     +121     
============================================
  Files          1302     1314      +12     
  Lines        252659   264085   +11426     
  Branches     212824   222740    +9916     
============================================
+ Hits         223498   232834    +9336     
- Misses        23791    25702    +1911     
- Partials       5370     5549     +179     
Components Coverage Δ
Rust Core 89.84% <96.15%> (+0.25%) ⬆️
Java SDK 70.14% <ø> (+1.33%) ⬆️
C# SDK 66.90% <ø> (-11.85%) ⬇️
Python SDK 90.38% <ø> (-0.69%) ⬇️
PHP SDK 85.84% <ø> (+0.16%) ⬆️
Node SDK 95.05% <ø> (-1.46%) ⬇️
Go SDK 70.39% <ø> (+0.14%) ⬆️
C++ SDK 84.43% <ø> (-1.95%) ⬇️
Files with missing lines Coverage Δ
core/binary_protocol/src/codes.rs 100.00% <ø> (ø)
core/binary_protocol/src/consensus/header.rs 83.57% <100.00%> (+0.21%) ⬆️
core/binary_protocol/src/consensus/operation.rs 97.40% <100.00%> (+0.08%) ⬆️
core/binary_protocol/src/consensus/request.rs 95.65% <100.00%> (ø)
core/binary_protocol/src/dispatch.rs 89.36% <100.00%> (+0.07%) ⬆️
...inary_protocol/src/primitives/partition_history.rs 100.00% <100.00%> (ø)
...protocol/src/requests/messages/get_send_context.rs 100.00% <100.00%> (ø)
...equests/partitions/install_consumer_group_owner.rs 100.00% <100.00%> (ø)
...equests/partitions/transition_partition_history.rs 100.00% <100.00%> (ø)
...y_protocol/src/requests/system/finalize_session.rs 100.00% <100.00%> (ø)
... and 173 more

... and 102 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

hubcio added a commit that referenced this pull request Oct 9, 2026
Purge reset a live partition's history in place. Its machinery
(generations, floors, a reset driver and durable markers) touched
every replay, repair, transfer, install and poll path. The feature
goes instead of being hardened further, with no compatibility path
for old clients, peers or data directories.

The Rust SDK, CLI, MCP tools, HTTP routes (now 404) and foreign
SDKs drop purge. Operations 131 and 135 and codes 205 and 305 are
retired and stay reserved. The metadata state machine loses the
purge handlers and generation. The reconciler pass, shard purge
frame, generation gates and deferred-purge metric go too. The
partition plane loses the purge driver, floor, purge.gen record
and WAL frontier marker. Without purge, the floor is always 0 and
ops start at 1, so the removed guards never change a result.

The queued offset history refusals stay, because a state transfer
install still resets the poll history. The no-ack history check
goes, because single-replica partitions never install a transfer.

New versions stop a node from misreading an older file: storage
marker IGGY-NO-PURGE-1, snapshot 10, offsets artifact 6 and WAL
frontier IGGYWAL4. They skip 9 and 5, because #4456 builds already
wrote them. Older data directories need --fresh, and old and new
replicas do not form a cluster.

The server dropped a client request with an undeclared operation
byte, so the lockstep connection stalled. Older clients still send
131 and 135. The server now answers InvalidCommand and echoes the
original byte, on the drain and over-queue paths.
@hubcio
hubcio force-pushed the feat/ownership-and-history branch from 35f833a to 219b99f Compare October 9, 2026 14:53
@hubcio hubcio added the breaking:storage On-disk data format change - skips backwards compat CI label Oct 10, 2026
@hubcio
hubcio force-pushed the feat/ownership-and-history branch from 57ef13d to 2536f1d Compare October 10, 2026 15:54
hubcio added 22 commits October 10, 2026 21:25
Queued requests, detached polls and retries can outlive their
consumer-group assignment or partition incarnation. Changing metadata
alone does not fence those operations at partition apply or recovery.

Order owner installs, owner retirement and delete fences in partition
logs. Require applied partition evidence before completing handoffs
or destructive metadata lifecycles. Retain owner and fence evidence
and lifecycle intents through checkpoints, restart and state
transfer. A committed delete fence closes the partition incarnation
for good. Admission drains admitted work before the fence, and the
partition refuses later requests and repaired prepares.

Reclaim deleted owner rows using replicated metadata evidence and
check the partition-set revision before finalizing sessions. Preserve
stable assignments and add an immutable fixed/mutable partition-resize
policy. Re-ack matching committed prepares without reapplying them.

Carry captured context through Rust and foreign SDK operations and
retain request context across uncertain retries. Add position-based
offset commits and update local stored progress after successful
offset-store calls.

Repair can journal batches out of operation order. Lower batches
then look persisted after a higher batch reaches disk. Restore
journal order before materialization and wait at operation gaps, so
that materialization does not drop those batches.

Protect acknowledged prepares above the receiver's known commit
when installing transferred state. Gate acknowledgements on the
contiguous WAL admission frontier, and keep recovery for
unacknowledged bodies above WAL gaps. Accept complete local repair
prefixes and cancel obsolete transfer re-arms after catching up.

Fail boot on incomplete segment-directory listings before recovery
can remove unseen committed logs. Use the configured wedge timeout
for file jobs, where zero disables it. Stop the node when a
timed-out job belongs to a tombstoned partition.

Consolidate superblock writes and request queue conditions while
preserving CREATE backoff behavior and lazy offset checks. Remove
unreachable dispatcher branches and redundant sampler/pipeline state.

BREAKING CHANGE: affects storage, replica-to-replica communication,
and SDK-to-server communication.

Storage: require the IGGY-OWNERSHIP-HISTORY-4 marker, metadata
snapshots v11 and ICO1 partition checkpoint/state-transfer data v7.
Reject incompatible data directories before mutation. This change
provides no in-place migration.

Replica-to-replica: prepare headers carry the partition incarnation,
offset prepares carry owner generations, and replicated control
operations and payloads change. Mixed-version replicas are
unsupported.

SDK-to-server: binary request/reply context fields and poll, routing
and topic response layouts change. The partition context is 24 bytes:
incarnation, owner generation and metadata op. Context-bearing SDK
APIs also change. Upgrade servers and compatible SDKs together.
Queue promotion compared the request incarnation with the
partition's and nothing else. A session retirement carries no
incarnation, so every partition with a nonzero incarnation
refused it once it waited in the queue. The liveness sweep only
retried, so sustained queue pressure kept dead sessions bound.
Promotion also skipped the deleted-history check of admission.

Admission and promotion now share one rule: session retirements
and lifecycle fences pass, and every other request needs the
live incarnation of a history that was not deleted.
A donor refused to offer an empty chain at frontier 0. A
partition that held owner installs, fences and offset stores but
no message could not catch up a replica whose repair window had
left the journals of its peers.

Dropping that gate alone was unsafe, because repair let a replica
with no committed message jump its commit floor over ops it never
saw. The jump also lost those owner installs, offset stores and
fences silently. Repair now refuses that jump, and the replica
takes a transfer instead, so an empty offer is real state.

Known residual: a replica that kept an external offset whose
delete left every journal refuses an offer that holds nothing,
until its group commits a message or an offset store.
Recovery can fence the only replica of a partition before it
mounts. A topic or group delete then waited for a lifecycle
completion that no node could report: the reconciler skipped the
unmounted partition, and its removal pass needed the namespace
to leave metadata first. The delete stayed pending forever.

On a single-replica cluster the reconciler now writes the
durable retirement fence for such a partition and completes the
lifecycle with RETIRED_PARTITION_OP, a partition op that no log
reaches. History and owner fences both take this path, because a
hung group delete would block the topic delete as well.
Snapshot validation searched the partition list of a topic for
every owner row and every lifecycle target, so recovery work grew
quadratically with partitions per topic. One index per topic
replaces the scans, and the first duplicate id still wins, as it
did for the scan.
Owner retirement sends every live group id of a topic in one
catalog, and decode refuses a catalog above 2^20 ids. Nothing
capped groups per topic, so a topic past that bound never
retired its owner rows, and the reconciler rebuilt the refused
catalog on every pass.

Group creation now fails at the bound with the new error
TooManyConsumerGroups (5010). Code 5001 stays unused, because it
named another error before.
ReplyHeader.owner_generation had no reader in core or in any SDK,
so it folds back into the reserved tail, which stays zero. The
40-byte poll head was written by hand in three places, and three
doc comments still described the old 16-byte head. Every site
now takes its bytes from PollMessagesResponseHeader, and a const
assert pins the 64-byte GetTopic partition record.
HTTP sends carried no context, so the server stamped the current
incarnation on receipt. A send retried across a partition delete
and recreate then appended to the replacement partition.

The send body takes an optional context in the shape the offset
store already uses, and the server fences with it when present.
The Rust HTTP client reads contexts from the topic details, keeps
them in the send-context cache, and on 87 reads them again and
resends once. It also retries 88 for every request, as the binary
transports do.
An 88 retry slept while it held the connection lock, so one call
that met a pending delete stalled every other request of the
client for up to 30 s. The pause now runs outside the lock, and
the retry takes a new request id once it holds the lock again.

The raw request API stamped a zero partition context, so the
server answered 87 to every raw send, poll and offset write. Raw
calls now take the typed paths: a send to an explicit partition
captures a context, polls and offset writes go to the partition
primary, and a send without a partition id fails with
FeatureUnavailable before anything is sent.
The interval and queued commit tasks of IggyConsumer dropped
every store error after the helper that logged them was removed,
while the docs still promised those reports. Both tasks now log a
failed store, and manual stores still return the error.

The docs now say that a poll or offset write can fail once with
87 after its partition was recreated, and that store_offset
commits under the context of the latest consumed message. One
buffered offset replaces the map that held it per partition.
In a cluster, offset writes went to the coordinator. A group commit
for a partition with another primary then moved the session there
under a new client identity. That identity was not a group member,
so the commit failed with 5009 and the client lost its membership.
Offset writes now go to the partition primary over a data
connection, as polls do. They take request ids from the coordinator
session, because the partition deduplicates by client and request
id.

SendBinaryRequest stamped no partition context, so the server
refused every raw send, poll and offset write with 87. Raw requests
now capture a context as the typed methods do and keep it across
retries. A balanced or key-partitioned raw send fails with
ErrFeatureUnavailable before it is written.

An 88 LifecycleBusy refusal returned at once. It now goes out again
as a new request with the same context, after a pause that doubles
from 50 ms to 1 s and holds no lock. PollingStrategy gains Context
and WithContext to continue a poll under an earlier context. After
the client deletes a stream or a topic, or creates or deletes
partitions, it drops every cached partition count and send context.
A topic cached by name and by id kept a stale alias before.
ErrTooManyConsumerGroups covers code 5010, and the docs describe the
one-off 87 or 5009 after another client recreates a partition.
A poll timeout could deadlock with an inline send. The send held the
router and waited for the poll monitor, while the timeout held the
poll monitor and waited for the router. The send now captures the
poll context with a compare-and-set and takes no poll monitor.

sendBinaryRequest stamped an empty partition context, so the server
refused raw sends, polls and offset writes with 87. Raw requests now
take the typed paths and keep their context across replays and
failover. A balanced or key-partitioned raw send, or a malformed
payload, fails before anything is sent.

In a cluster, offset writes went out on the main connection. They
now go to the partition primary through the poll router. A shared
session takes request ids from its parent, because the partition
deduplicates by client and request id. ConsensusSession.bindShared
now takes that parent session. A TCP request refused with 88
LifecycleBusy failed at once. It now goes out again as a new request
with the same context, after a pause that doubles from 50 ms to 1 s
and holds no lock. HTTP does not retry 88 yet.

HTTP sends carried no context, so they landed on whatever
incarnation the partition had on arrival. A send to an explicit
partition now carries the context from the topic details and goes
out once more after an 87. PollingStrategy gains an optional context
component and withContext. TCP polls stamp the context, and HTTP
polls send it as a query parameter. The send-context cache dropped
an entry on any failure and all of them at 4096 entries, but none
after the client's own topology changes. Now only an 87 drops
entries, all of them for its topic, and the client clears the cache
after it deletes a stream or a topic, or creates or deletes
partitions. IggyErrorCode gains TOO_MANY_CONSUMER_GROUPS (5010),
CommandCode.ConsumerOffset gains DELETE, and the docs describe the
one-off 87 or 5009 after another client recreates a partition.
After another client recreated a partition, IggyConsumer dropped the
first messages of the new incarnation as duplicates and stored the
old offset under the new context. It also polled every partition
with one shared strategy, which it moved to Offset(n + 1) without a
context. A recreated partition was then read past its first
messages, a group member read one partition from the offset of
another, and First or Timestamp stalled on their first batch.

Each partition now continues at Offset(n + 1) under the context of
the batch that delivered n. A new incarnation or owner resets the
duplicate filter, and an 87 or 5009 drops the position before the
consumer reports the error. IIggyConsumer gains PollMessagesAsync
and PollMessagesRentedAsync overloads that take a strategy per
partition. A late commit used the context of the latest poll and
could land in a newer incarnation. ReceivedMessage,
ReceivedRentedMessage and RentedBatchHandle now carry the Context of
their poll, which AfterReceive commits and a new
IggyConsumer.StoreOffsetAsync overload use.

In a cluster, manual-commit polls and offset writes went to the
coordinator. They now go to the partition primary, and data
connections share the client's consensus session, so request ids
never repeat. A manual-commit poll whose primary connection drops
goes out again, since it commits nothing. A raw Balanced or
MessagesKey send fails with FeatureUnavailable instead of going out
with a zero context. TCP requests refused with 88 LifecycleBusy
retry as new requests, after a pause that doubles from 50 ms to 1 s.

PollingStrategy gains Context and WithContext. HTTP sends carry the
context from the topic details and go out once more after an 87,
and HTTP polls send a caller context. Send contexts leave the route
cache, which dropped them on any failure, on any metadata write of
the client and at 4096 entries. Now only an 87 on their topic drops
them, and the client clears them all after it deletes a stream, a
topic or partitions, or creates partitions. The docs describe the
one-off 87 or 5009 and the 5010 limit on consumer groups.
After a leader move, the client re-issued queued commands without
their captured context. A send could then refresh its context twice,
and an offset store could commit into a newer incarnation. Re-issued
commands now keep their context, deadline and flags.

On a cluster, offset writes went out on the main connection, and a
refusal from a node that was not the primary moved that connection
and its session. They now go to the partition primary over a data
connection that shares the main session, so request ids never
repeat. On a single node, every poll and offset write asked for its
route first. Routes are now cached until the session generation or
the metadata watermark moves.

Callers could not pass a partition context. PollMessages,
StoreOffset, DeleteOffset and SendCommandOptions gain an optional
context, and every retry keeps it. A raw send without an explicit
partition id fails with code 5 before it is written, and a malformed
partition payload fails with code 3. An 88 LifecycleBusy refusal
returned at once. It now goes out again as a new request, after a
pause that doubles from 50 ms to 1 s. Send contexts are no longer
cleared at 4096 entries. An 87 drops those of its topic. After the
client deletes a stream, a topic or partitions, or creates
partitions, it drops them all and the cached partition counts. Error
code 5010 now maps to its message, and the TSDoc and README describe
these rules.
The binding dropped the partition context of every received message.
store_offset commits under the context of the latest consumed
message, so a held message could not commit under the context that
delivered it, and a poll could not continue under an earlier one.

ReceiveMessage gains context() and position(), IggyConsumer gains
store_position(), IggyClient.poll_messages takes a keyword-only
context, and Partition gains a context property. PartitionContext
and ConsumerPosition are new classes with public constructors, so a
saved checkpoint can be rebuilt. The docs describe the one-off 87 or
5009 after another client recreates a partition.
The bridge dropped the partition context of topic partitions and
polled batches. C++ callers could not poll under a context or store
an offset under the one that delivered it, so a delayed store took
the context of its route and could land on a recreated partition.

The ffi Partition and PolledMessages gain a context field, and
poll_messages_with_context and store_consumer_position are new ffi
calls. The high-level API gains iggy::PartitionContext,
Partition::Context() and IggyBlockingClient::StoreConsumerPosition().
The docs describe the one-off 87 or 5009 after another client
recreates a partition.
The binding dropped the partition context on every receive path.
Consumer::storeOffset commits under the context of the latest
consumed message, so after a recreate or an owner change a commit
could land on the newer partition. A poll also could not continue
under an earlier context.

ReceiveMessage gains context() and position(), PollingStrategy gains
withContext() and Consumer gains storePosition(). The new
Iggy\PartitionContext and Iggy\ConsumerPosition classes have
constructors, so a saved checkpoint can be rebuilt. The README
examples now commit with storePosition(), and the docs describe the
one-off 87 or 5009 after another client recreates a partition.
The server now refuses a consumer group beyond the per-topic limit
with 5010, and the Swift SDK reported that code as unknown. The new
tooManyConsumerGroups case names it. The golden fixture gains the
same row, so the table still matches the server's error enum.
A group poll was checked against the serving node's metadata only.
That metadata can lag an owner install the partition already applied,
for example on a new primary after a view change, so a replaced owner
could still read and auto-commit under the new owner's token.

The poll gate now compares the poller with the owner installed on the
partition. A missing or older install means this replica has not
applied it yet and returns 58, so the client retries. A newer install,
another client or an unassigned owner returns 5009, so the client
re-syncs at once. Completion repeats the check, refuses an unassigned
owner before preparing its store, and first resynchronizes the install
latch, because a view change rebuilds it.

A view change can leave several installs unapplied while the latch
names only the last one. A barrier at the op of the last unapplied
install now holds group reads and group offset writes until all of
them have applied. Without it, a store admitted under a replaced owner
failed at apply with a fatal commit.
HTTP has no request dedup. When Apache HttpClient resends a write
after a 503 or an I/O failure, the first attempt may have committed.
A refusal of the resend (87, 88, 41 or 40) says nothing about that
attempt, but the send path treated it as certain: it read the topic
again and posted the batch a third time.

The client now marks a request uncertain when its retry strategy
approves a resend, except after a 429, which proves the server did
not take the attempt. A settled refusal of an uncertain write is
reported as 57, with the refusal as its cause, so nothing refreshes
or repeats it. Reads are never uncertain.
The async TCP connection retried a LifecycleBusy (88) refusal until
the request deadline, even after the caller cancelled or timed out
its future. The request could then apply after the caller saw it
fail.

Each exchange now carries the caller's future, and the retry stops
once that future is done. Typed client methods return dependent
stages that do not pass a cancel or timeout back to the connection,
so updateStream(...).orTimeout(...) still retries until the deadline.
A state transfer wipes the log above its commit op, but it left the
owner install barrier as it was. A barrier above the installed commit
op then refused every group read and group offset write with 58. The
sequencer equals commit_min after the install, so on an idle partition
nothing committed past the barrier, and group consumers stalled until
the next view change.

The install now clears the barrier with the latch. A scan of the
empty log above commit op would also return 0, and the checkpoint
already carries every owner installed up to it, so no unapplied
install is skipped.
hubcio added 18 commits October 10, 2026 21:25
A join now returns before the member owns any partition, because each
partition must first install the new owner. The first group poll
after a join therefore synced an empty assignment, and the Go client
trusted it for 5 s, so group polls and consumers returned nothing for
that long after every join.

Sync again on the next poll while the assignment is empty, as the
Rust and Node SDKs do. A member that owns no partition now syncs once
per poll instead of once per 5 s.
A join now returns before the member owns any partition, because each
partition must first install the new owner. The first group poll
after a join therefore synced an empty assignment, and the Java client
trusted it for 5 s, so group polls and consumers returned nothing for
that long after every join.

Sync again on the next poll while the assignment is empty, as the
Rust and Node SDKs do. A member that owns no partition now syncs once
per poll instead of once per 5 s.
A join now returns before the member owns any partition, because each
partition must first install the new owner. The first group poll
after a join therefore synced an empty assignment, and the C# client
trusted it for 5 s, so group polls and consumers returned nothing for
that long after every join.

Sync again on the next poll while the assignment is empty, as the
Rust and Node SDKs do. A member that owns no partition now syncs once
per poll instead of once per 5 s.
The reconciler completes a revocation or a group delete only after
the partition proves the owner install. The proof required
commit_min == commit_max, but select_commit publishes an install
alone, so a send committed behind it leaves commit_min below
commit_max. Under steady traffic the proof never appeared, and the
join or delete stalled until the writes stopped.

Prove the install once commit_min reaches its op instead. Apply
writes the row before the walk publishes, so a row above commit_min
still proves nothing, and an op at or below commit_min is committed,
so no view change can drop it.
A topic resize rebalances every consumer group. rebalance_members
inserted an ownerless row for each partition before it checked for
an owner, so a group that never had a member got one row per
partition on every resize. With many idle groups and partitions,
the metadata state and every snapshot grew without bound.

Return early when the group has no members and no rows. A group
that already holds rows still gets a row for each new partition:
snapshot validation accepts no rows or one row per partition, so
skipping only the new partitions would fail the restore.
Every partition the filter sees comes from the member's own
partition list, so the membership half of is_pollable is always
true there and only adds a linear scan per element. Filter against
the pending revocations alone.
With replay disabled, store_offset on a partition with nothing
consumed yet went straight to the server. It neither checked nor
updated the guard in a way later stores could compare: the record
carried an empty context, and the guard compares only within one
incarnation and owner. So store_offset(100) then store_offset(10)
rewound the server to 10, and a later lower auto-commit, position
store or shutdown flush did the same. The base refused all of these.

An offset stored without a captured context now counts against
stores of any context, and the path without a consumed message
checks the guard first. The client does not return the context it
captured, and HTTP has none, so the record cannot hold it. The
Python binding uses this state, so its docs say the same.
The partition journal answered last_op() with the op of its tail
header and assumed appends arrive in op order. Repair breaks that:
it can journal an owner install at n+2 before the send at n+1, and
the journal stays unsorted until a flush sorts it. The first offset
reservation scan of the next view stopped at the tail, missed the
install and cleared the install latch. A store under the replaced
owner was then admitted, failed at apply, and fenced the partition.

Read last_op() off the op index instead, which is what the Journal
contract says and what the metadata journal does. A scan of the
whole sequencer range instead counts ops that are not resident and
marks offset capacity uncertain. The fix also covers the other
callers: the shutdown flush target and the shard sweep for ops above
the announced head no longer stop below a backfilled op.
A lifecycle fence applies its owner, history and retirement state
before its commit publishes commit_min. On a persisted partition
with an I/O dispatcher, that commit can wait for a directory sync.
A checkpoint due in that window captured its receipts at the old
commit_min but with the fence already applied, and published them
as that op. Recovery then refused the owner or history row stamped
with the later op and failed with StateFileCorrupted.

Do not capture a checkpoint while the pending commit carries a
lifecycle fence. The flag that asks for a checkpoint stays set, so
the next shard tick captures it after the fence publishes. A fence
only waits for a checkpoint that is already enqueued, never for
one that is merely due, so the two cannot wait for each other.
A client can carry a partition context from a node that applied
more metadata than this one. The TCP and HTTP poll gates and the
partition admission compared the incarnation and the owner before
the metadata op. So a context naming a partition incarnation or
owner this node had not applied yet got HistoryUnavailable (87) or
ConsumerGroupPartitionNotOwned (5009), both final. The consumer
then dropped its position, and a sender dropped its context.

Check the metadata op first and answer TransientNotAccepted (58)
while this node is behind the caller. Once it applied the caller's
metadata, a mismatch is final as before. The TCP and HTTP poll
gates now share one function, so the order cannot drift apart.
A partition treats an owner retirement catalog as a pure function of
its metadata op: two catalogs with the same op and different groups
fail at apply and fence the partition. The reconciler read the
topic's groups in one metadata read and labeled them with the
applied frontier in a later read. On a shard other than 0, shard 0
can remove a group in between, so one catalog kept the group under
the removal's op and the next pass dropped it under the same op.

Keep in each topic the op of the last apply that changed its group
set or next group id, and read it together with the groups. A group
removed by lifecycle finalization takes the completion op, because
a sibling group created after the intent can hold a later op. The
frontier cannot serve as the label even when read first: it moves
after publish, so a reader can see groups one op ahead of it. The
v11 metadata snapshot gains the field as a trailing default, which
is safe because v11 is unreleased.
Deleting a stream with 1000 partitions committed one
CompleteLifecycle op per partition. Each commit woke every shard,
and a pending fence turned the wake into a full reconcile pass that
sent every fence and every completion again. The work grew with the
square of the partition count. On 16 shards the inbox of shard 0
filled and refused client forwards, and the Python CI teardown that
deletes 1000 partitions stalled for 30 s.

One CompleteLifecycle op now carries every installed target of a
shard, in canonical order and at most LIFECYCLE_COMPLETIONS_MAX. A
shard keeps one batch in flight under its own internal client, so
the batches of two shards do not refuse each other as in progress.
Only a batch that applied wakes the shard again, so a lasting
refusal cannot loop. The apply records the whole batch or nothing,
and a finalization that fails reopens every target it recorded.

The lifecycle step runs on every wake, outside the full pass, and
sends a fence again only 100 ms after the last send. The op body
changes, which is safe because v11 is unreleased.
A home shard forwards a metadata write to shard 0 and relays the
committed reply. When no verdict came back, for example because the
inbox of shard 0 refused the forward, TCP dispatch and delete
segments sent nothing, and the client replayed only after its 30 s
read timeout. The HTTP write path answered a plain 503 at once.

Answer TransientNotCommitted instead. The outcome is unknown, and
this code allows only a replay of the same request id, which the
client table answers from its cache if the op committed. Every SDK
already replays it on the same connection. The HTTP path replays
it in place, like the other transient frames, until its budget
ends.
A store_offset() made before anything was consumed has no captured
context, so the replay guard compares it with stores of every
context. Every stored offset covers offset 0. After the partition
was deleted and created again, the consumer therefore skipped the
first offset of the new partition, and it never reached the server.

Master never skipped offset 0. Bring that rule back for a
comparison that involves a store without a context. Offsets above
0 keep the guard, so a lower auto-commit or flush still does not
move the server back behind such a store.
A replica applies the delete fence from its partition log, and its
metadata can apply the delete later. Until then the metadata still
lists the partition and authorizes polls of the old incarnation.
Completion refused a deleted history only in the auto-commit
admission, so a poll without auto-commit, or with an offset that
was already durable, got the deleted messages.

The poll gate and poll completion now answer HistoryUnavailable
(87). Both checks run after the incarnation match, so a poll for a
newer incarnation still gets the transient 58.
A primary-elect defers dropping the log suffix that its new view
discards. An acknowledgement that arrives first scans the log in
the new view and latches an owner install from that suffix. The
truncation then drops the install, and the next scan in the same
view kept the latch. The install never published, so the partition
refused every later install for the group, and the polls and
offset writes of the group, until the next view change.

A truncation now makes the next scan clear the latch and re-arm it
from the retained log, without waiting for the shard tick.
Every wake of every shard ran the lifecycle step, and the step
cloned all pending intents with their targets and partition
indexes, then dropped the copy. The retired pass on a single
replica cloned them again. A delete of 1000 partitions cost about
100 allocations per wake on each shard.

Both passes now select inside one metadata read and copy out only
the due fences, the one bounded batch, and the targets that failed
recovery. The step for 1000 targets on other shards drops from
about 11 to 3 microseconds. The read now lasts for the selection,
about 17 microseconds when all 1000 targets are local.
Every binary poll asked twice whether a pending lifecycle blocks
its consumer, and each query scanned the intents of every stream.
Offset commits and request admission did the same. A backlog of
deletes elsewhere made every poll slower, by about 2 microseconds
per query at 1000 intents.

A set of (stream, topic, op) keys next to the intents orders them
by scope, so a query reads only the stream-wide intents of its
stream and the intents of its topic. Every insert and removal of
an intent updates the set, and a restore rebuilds it, so the
snapshot encoding stays the same. The query takes about 35 ns.
@hubcio
hubcio force-pushed the feat/ownership-and-history branch from eb0bea7 to 7d75e52 Compare October 10, 2026 19:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking:storage On-disk data format change - skips backwards compat CI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Go SDK: a manual consumer-group commit to a partition whose primary is not the coordinator drops the group membership and is refused

3 participants