8000 chore(inkless:release): cherry-pick main changes into inkless-4.3 for 0.53 by gqmelo · Pull Request #936 · aiven/inkless · GitHub
[go: up one dir, main page]

Skip to content

chore(inkless:release): cherry-pick main changes into inkless-4.3 for 0.53 - #936

Merged
jeqo merged 35 commits into
inkless-4.3from
inkless-4.3-0.53
Dec 4, 2026
Merged

jeqo merged 35 commits into
inkless-4.3from
inkless-4.3-0.53

Conversation

@gqmelo
@gqmelo gqmelo commented Dec 3, 2026 •
Copy link
Copy Markdown
Collaborator

Cherry-picks the 33 commits that main gained since inkless-release-0.52 into inkless-4.3 for the 0.53 release, up to 1247174 (#927). The branch doesn't need an upstream sync: 4.3 already holds the upstream version of 0.52. branch-consistency.sh skips #919 as sync tooling.

ca375e2131 comes after the 33 picks. It reached main inside the upstream sync merge #897, so branch-consistency.sh doesn't list it. Without it, make docs regenerates the jOOQ sources under JDK 17, which drops the this-escape suppression, and the Compile and Check Java job fails on the dirty tree.

Every commit applied without a conflict. The last commit, sync(compile), adapts the picked tests to the 4.3 APIs. On 4.3, the ConfigurationControlManager alter methods take a forwarded flag that the #899 tests didn't pass. The #927 test also needs a LogConfig import that main already had. The same commit excludes SKIPPED_CLASS_TOO_BIG for kafka.server.ReplicaManager in the SpotBugs filter, because the picks push the class past the analysis limit on 4.3. inkless-4.1 has had the same exclude since 0.51.

Commits

See the commit messages for the reasoning behind each change.

Release notes

Testing

These suites pass with no failures:

  • :storage:inkless:test: 1504 tests.
  • :metadata:test for ConfigurationControlManagerTest, ReplicationControlManagerInklessTest, TopicImageNodeTest, and PartitionRegistrationTest: 347 tests.
  • :core:test for the Inkless cluster tests that the picks change, io.aiven.inkless.consolidation.*, DelayedFetchTest, DisklessFetchOffsetRouterTest, DynamicConfigChangeTest, InklessControlPlaneConnectionStringValidatorTest, and ReplicaManagerInklessTest: 663 tests.
  • :clients:test for AppInfoParserTest and :tools:test for TopicSwitchCommandTest: 30 tests.

Checkstyle passes for storage:inkless, core, and metadata. SpotBugs passes for storage:inkless and core.

🤖 Generated with Claude Code

giuseppelillo and others added 30 commits December 3, 2026 13:31
…c-to-diskless switch [KC-717] (#882)

* feat(inkless:switch): elect a chosen replica in phase 1 of the classic-to-diskless switch [KC-717]

In phase 1 of the classic-to-diskless switch, only the replicas' local
disks store the classic prefix, and the controller blocks unclean leader
election. If the only ISR member loses its disk, the partition goes
offline, and neither `rearm` nor `lower-seal` moves leadership to a
replica that still has the prefix.

`kafka-topic-switch.sh elect --replica <broker-id>` elects the chosen
replica, even if it's outside the ISR. The command sends
`AlterDisklessSwitch` with a new `LeaderId` field and a seal offset of
`-1`. The controller runs an unclean election that accepts only that
replica: it resets the ISR to a replica outside the ISR and sets the
leader recovery state to `RECOVERING`. The election runs with or without
a leader, with a pending switch or a committed seal. The phase 1 guards
on unclean leader election don't change.

`ReplicationControlManagerInklessTest` and `TopicSwitchCommandTest`
cover the election and its rejections.
`InklessTopicTypeSwitcherClusterTest` recovers a partition end to end
after its last ISR member goes away.

Assisted-by: Claude Fable 5.2

* test(inkless:switch): block remote uploads with a gate in the phase 1 election test [KC-717]

The election test kept its partition in phase 1 with a one-hour remote
copy interval. The broker schedules the first copy run with no delay,
and the test didn't wait for that run, so a late first run could upload
the classic prefix and start phase 2 before the election.

The test now configures `GatedRemoteStorageManager`, a wrapper around
the tiered storage plugin that rejects segment uploads while the test
blocks them. The copy interval is back to the value the other tests
use. After the old leader rejoins the ISR, the test unblocks the uploads
and waits for phase 2.

Assisted-by: Claude Fable 5.2

* docs(inkless:switch): say that electing an ISR member keeps the ISR [KC-717]

The Javadoc of `Admin.alterDisklessSwitch` said that every election
resets the ISR to the chosen replica. The controller resets the ISR only
for a replica outside the ISR, and keeps it for an ISR member. The
Javadoc now describes both cases.

Assisted-by: Claude Fable 5.2

* test(inkless:switch): block remote uploads with a missing bucket instead of a wrapper class [KC-717]

Gradle assigns the test classes of `:core:test` to its two forks in
turn, by class file. The nested `GatedRemoteStorageManager` class added
a class file, and every class after it
8000
 moved to the other fork. Both
256-second cluster test classes then ran on the same fork. `:core:test`
took 17 minutes instead of 11, and the CI test step reached its
30-minute limit.

The election test now needs no new class. For this test, the setup
configures the tiered storage plugin with a bucket that doesn't exist,
so segment uploads fail and the partition stays in phase 1. The test
creates the bucket after the recovery and waits for phase 2.

Assisted-by: Claude Fable 5.2

* fix(inkless:switch): reject the election of an adding replica outside the ISR [KC-717]

In phase 1 the controller stages a reassignment, so an adding replica
is a replica of the partition before it joins the ISR. `elect` accepted
such a replica and reset the ISR to it. The next partition change then
completed the reassignment and dropped the removing replicas, which can
store the only copy of the classic prefix.

The controller now rejects the election of a replica that a
reassignment is adding and that is outside the ISR. The election of any
other replica stays possible during a reassignment.

The controller also rejects an election whose record would complete a
reassignment. `PartitionChangeBuilder` completes a reassignment before
it elects a leader. If the chosen replica was a removing replica, the
record set no leader for the partition.

Assisted-by: Claude Fable 5.2
…al after lower-seal [KC-837] (#889)

* docs(inkless:switch): document how to move local logs past the old seal after lower-seal [KC-837]

`lower-seal` moves the committed seal below the offset where the
diskless log starts. Consolidation appends the diskless records at the
old seal, so each replica's leader epoch cache maps the lost offsets to
a classic epoch. While a replica holds local segments below the old
seal, a broker restart or a leader change makes replicas truncate or
recreate their consolidated records, and a follower can stop
consolidating.

`lower-seal` only follows a last-known-leader election in phase 1 that
lost records, so this change documents a manual procedure and doesn't
change the broker. The procedure forces local retention past the old
seal, after which restarts and leader changes leave the replicas alone.

Assisted-by: Claude Fable 5.2

* docs(inkless:switch): fix the order and the config restore of the lowered-seal procedure [KC-837]

The procedure asked for the old seal after `lower-seal` replaced it, so
the recovery steps now take it from the broker message that marks the
partition offline. A replica that stopped consolidating can't pass the
segment check, so the leader restart no longer waits for it. The last
step restores the topic configs to their previous values.

Assisted-by: Claude Fable 5.2

* docs(inkless:switch): state that the lowered-seal procedure needs a diskless record [KC-837]

Without a diskless record, every local log ends at the new seal, so no
segment can start past the old seal and the wait in step 2 never ends.
The broker also has nothing to truncate in that state. The procedure
now starts after the first diskless record, and the restart restriction
applies from that record on.

Assisted-by: Claude Fable 5.2
…KC-838] (#885)

* test(inkless:switch): hold each switch step before injecting faults [KC-838]

The Category B fault tests injected the fault right after the config
change, so the protocol step that the fault hit was a race. They also
used a degraded network and 30 partitions to stretch the steps, which
made them the slowest switch tests.

`test_fault_before_control_plane_init` replaces them. A network partition
holds step 3 in `WaitingForReplication`, and a Postgres outage after the
seal commit holds step 5 in `AwaitingMetadata`. Each run injects its
fault inside a hold, asserts that the hold is still in place unless the
fault ends it, and then releases it. The runs cover a follower and a
leader crash, a controller failover before the seal commit, a frozen
leader, and a rolling restart while Postgres is down.

Category D runs also cover the remaining client and operator paths:

- `controller_failover_at_phase_2` kills the leader of partition 0 while
  its flag request is pending.
- `reassignment` moves a follower in phase 2 under load, then reads the
  partition through the new replica alone.
- `object_storage_outage` resumes a consumer group before the switch, in
  phase 1, and in phase 2, and reads its committed offsets back. It
  checks `ListOffsets` for the latest, earliest, timestamp, and
  max-timestamp specs in phase 1 and through each broker in phase 2.

A lowered seal that enters phase 2 needs no system test:
`ClassicToDisklessSwitchLastKnownLeaderClusterTest` lowers the seal,
restarts the leader, waits for phase 2, and reads every record.

Assisted-by: Claude Opus 5.5

* test(inkless:switch): keep held-step producers retrying [KC-838]

Three runs of `test_fault_before_control_plane_init` failed on
records that the producer couldn't send: the replication hold with a
leader SIGKILL and with a controller failover, and the control-plane
hold with a rolling restart. `VerifiableProducer` sets `retries` on the
client as well as the delivery timeout, so `retries=20` capped each
record at 20 attempts. A broker that is down or sealed rejects a send
within a second, and the backoff stays at 1 s, so a record used up its
attempts long before the hold ended.

The held runs now use `retries=1000`, which keeps a record alive for
1,000 attempts and 8 hours. A failed send now also reports the
exception and message of the first errors from the producer output.

Assisted-by: Claude Opus 5.5

* test(inkless:switch): check the commit epoch and the faulted broker's state [KC-838]

Review found three gaps in the new checks:

- `VerifiableConsumer` reports the size of the whole last poll, even when
  `--max-messages` stops it partway. `_consume_with_group` no longer
  compares that count. The callers already check the committed offsets.
- A manual commit of `VerifiableConsumer` doesn't include a leader epoch,
  so the phase 2 resume skipped the epoch check of its position. The
  phase 1 resume now auto-commits on close, with the epoch of the last
  classic record, and the test reads the commits from
  `__consumer_offsets` to assert the epoch before phase 2.
- The cluster-wide state waits can pass on another broker's history.
  Before a leader fault, the tests now wait for a fresh sample of the
  leader's own gauges: `SendingFlagToController` before the kill in
  `controller_failover_at_phase_2`, and the hold state before a leader
  SIGKILL or SIGSTOP in `test_fault_before_control_plane_init`.

Assisted-by: Claude Opus 5.5

* test(inkless:switch): decode concatenated commits and wait for the partition rules [KC-838]

`OffsetsMessageFormatter` writes the records without a separator, and
`ConsoleConsumer` doesn't add one. Parsing each output line as one JSON
object dropped every commit, so the `object_storage_outage` run would
fail its leader epoch check. `_committed_offsets_with_epochs` now
decodes the output as a run of JSON objects.

`create_task` returns before the Trogdor agents install the iptables
rules. The held-step test now waits until every agent reports the
network partition in place, and until partition 0 stops getting acks,
before it switches the topic. Without that, the switch could seal a log
that the follower had already caught up on.

Assisted-by: Claude Opus 5.5

* test(inkless:switch): count only fresh samples when asserting a hold [KC-838]

`_assert_switch_state_held` summed the newest sample of each live
broker through `_live_cluster_jmx_sum`, which doesn't check sample
times. `_restart_broker_jmx_tool` keeps the samples from before a
restart, so after a restart or a pause the newest sample could predate
the fault, and the assertion could pass without the hold surviving it.
The assertion now requires a sample from each live broker taken after
the call starts.

Assisted-by: Claude Opus 5.5

* test(inkless:switch): leave records in every partition for the phase 1 resume [KC-838]

The `object_storage_outage` run failed its leader epoch check on
partition 2. The group's first run read 3,000 records and drained that
partition, which held 1,653. Its manual commit at the seal doesn't
include an epoch, and the phase 1 resume fetched nothing from it, so the
commit at close had no epoch either. The first run now reads half the
records of the smallest partition.

Assisted-by: Claude Opus 5.5
…g it [KC-855] (#895)

The `topicId` helper in `InklessControlPlaneOutageClusterTest` called `describeTopics` right after `createTopics`. The controller has the topic at that point, but the broker that answers can still lack the metadata, so the call threw `UnknownTopicOrPartitionException` in CI. The helper now calls `TopicMetadataProbe.awaitVisible` first, as other cluster tests do.

Assisted-by: Claude Sonnet 5.5
The push trigger matches inkless-4.*, which also matches release-prep
branches such as inkless-4.3-0.52. A push to such a branch with an open
pull request starts Inkless CI twice on the same code: once for the push
and once for the pull request.

Exclude names with a suffix after the version. The release branches
(inkless-4.0 to inkless-4.3) keep their push runs. The other excluded
branches (rc, sync, and wip branches) get CI from their pull request.

Assisted-by: Claude Opus 5.5
…hes of a switched partition [KC-852] (#896)

* fix(inkless:switch): stamp the diskless leader epoch on consumer fetches of a switched partition [KC-852]

Diskless produce writes every batch with leader epoch 0, and a switched
partition served those batches to consumers as stored. A consumer that read
past the seal validated its position with epoch 0, the local classic log
answered with the end of classic epoch 0, and the consumer reset to the seal
and re-read every record from there.

Epoch 0 is also a real classic epoch, and an OffsetsForLeaderEpoch request
carries no offset, so the broker can't tell that consumer from one whose
classic records the partition lost before it sealed. A switched partition
now serves diskless batches with the diskless leader epoch, as the
consolidated local log does. The classic log answers a requested epoch up to
the last classic leader epoch, and a greater epoch gets the diskless end
offset, which is at least the committed seal.

Assisted-by: Claude Fable 5.2

* fix(inkless:switch): route OffsetsForLeaderEpoch by the initial diskless leader epoch [KC-852]

Comparing the requested epoch with the last classic leader epoch gave two
wrong answers. A classic epoch whose records the partition lost entirely is
above the last surviving classic epoch, so it got the diskless end offset and
the consumer skipped the records that replaced the lost ones. An abort marker
that the sealed leader writes is in the leader epoch of the seal commit, which
is also the diskless leader epoch of phase 1, so a consumer past the seal got
the classic answer and reset to the seal.

The diskless leader epoch of the seal commit separates the two kinds of epoch,
but the controller sets disklessLeaderEpoch again when phase 2 starts. The
partition registration now keeps the first value in initialDisklessLeaderEpoch
(tag 105). The classic log answers a requested epoch below it, and that epoch
and later ones get the diskless end offset. A partition that switched before
the registration kept the value compares with disklessLeaderEpoch.

Assisted-by: Claude Fable 5.2

* fix(inkless:switch): answer a classic epoch with the seal when the local log has no end offset at or below it [KC-852]

A follower caches the leader epochs of the batches it appends. If the
partition lost every record of a classic epoch, a follower that appended no
batch afterward has no cached epoch above it, and its local log has no end
offset for that epoch. The broker then asked the diskless log, whose end
offset told a consumer that had read the lost records to keep its position,
and the consumer skipped the records that replaced them. The leader answered
the same request with the seal.

An epoch below the initial diskless leader epoch is a classic epoch, and a
classic epoch ends at the seal at the latest. For such an epoch, the broker
now answers with the seal when the local log has no end offset or has one past
the seal.

Assisted-by: Claude Fable 5.2
…false (#899)

* fix(inkless:controller): reject a topic type flag that isn't true or false

`ConfigDef` trims a boolean before it parses it, so a create or an alter
accepts `diskless.enable=" true"`. The controller stores the raw string
and reads it with `Boolean.parseBoolean`, which doesn't trim. The
validation then reads the topic as diskless, and the controller reads it
as classic. The brokers fail the requests that read the flag while the
value is stored.

The controller makes two wrong decisions from that value:

- An alter that corrects the value to `true` looks like a
  classic-to-diskless switch. The controller marks the partitions of a
  born-diskless topic as switch-pending, and the leader runs the switch
  on them.
- The check that keeps diskless enabled reads the stored value as
  `false`, so it doesn't stop an alter to `false`.

The controller now rejects a topic `diskless.enable` or
`remote.storage.enable` value that isn't `true` or `false`, in any case,
with `INVALID_CONFIG`. `validateAlterConfig` runs the check. A create, an
incremental alter, and a legacy alter all pass through it, so a rejected
request writes no records. The controller also rejects such a
`remote.storage.enable` value for a classic topic.

## Testing

- `ConfigurationControlManagerTest`: `testRejectPaddedTopicTypeFlag` and
  `testAcceptTopicTypeFlagInAnyCase`, for both keys.
- `ReplicationControlManagerInklessTest`: a value with surrounding
  whitespace followed by `true` or by `false` on a born-diskless topic,
  through the incremental and the legacy alter, on a classic topic with
  the switch allowed, for `remote.storage.enable`, and at topic creation.
- Both classes pass with the change: 284 tests. Without the change to
  `ConfigurationControlManager`, the 9 new tests that expect a rejection
  fail.

Assisted-by: Claude Opus 5.5
Assisted-by: Claude Fable 5.2

* docs(inkless:controller): say why the controller rejects only the topic type flags

A reviewer asked whether the mismatch between `ConfigDef` and the stored
value exists in upstream Kafka too. It does, for
`unclean.leader.election.enable`: `uncleanLeaderElectionEnabledForTopic`
reads the stored value with `Boolean.parseBoolean`, so the controller
reads a value with surrounding whitespace as false and skips the unclean
election. For `diskless.enable` and `remote.storage.enable` the
controller writes the switch and consolidation markers of the partitions
from the value, which is why it rejects the value for these two keys. The
comment on the check now says so.

Assisted-by: Claude Fable 5.2
…s below the seal [KC-866] (#901)

* fix(inkless:switch): don't answer a classic epoch from a log that ends below the seal [KC-866]

In phase 2 any replica can lead, including one with an empty local log,
such as a replica that a reassignment adds. `Partition.makeLeader` maps
the new leader epoch to the log end offset in the leader epoch cache, and
the broker keeps the partition online so that consolidation rebuilds the
log. Until then `ReplicaManager.lastOffsetForLeaderEpoch` answered
`OffsetsForLeaderEpoch` for a classic epoch from that cache, with an end
offset below the seal. A consumer at or below the seal treats that answer
as a truncation.

On a 3-broker cluster, after a reassignment of a phase 2 partition sealed
at 20 to a broker without a log, the new leader answered a classic epoch
with end offset 0 for about 6 ms. In one of three runs the validation of
an idle consumer got that answer, and the consumer read offsets 0 to 19
again.

A replica whose high watermark is below the seal now answers a classic
epoch with `NOT_LEADER_OR_FOLLOWER`. This rule already applied to a
follower, and now applies to the leader too. The consumer retries the
error. Consolidation rebuilds the log from remote storage, or starts it at
the cross-tier earliest offset if the prefix is already deleted. Both
steps set the high watermark to the seal or a later offset, and the
lookup then succeeds. Phase 1 doesn't change: a leader below the seal
marks the partition offline there.

## Testing

- `ReplicaManagerInklessTest` has two new tests, for a phase 2 leader
  with an empty log and for one whose log ends below the seal. Both fail
  without the change to `ReplicaManager`. The class passes with 316
  tests.
- On a 3-broker cluster, a temporary test repeated the reassignment three
  times with a loop that sends `OffsetsForLeaderEpoch` for the classic
  epoch to the new leader. The leader answered `NOT_LEADER_OR_FOLLOWER`
  and then the seal, about 1.1 seconds after the reassignment. The idle
  consumer kept its position and received only the next record.
- `:core:checkstyleMain`, `:core:checkstyleTest`, and
  `:core:spotbugsMain` pass. `make vale` reports no alerts.

Assisted-by: Claude Opus 5.5
Assisted-by: Claude Fable 5.2

* fix(inkless:switch): log a deferred classic epoch lookup

A consumer retries `NOT_LEADER_OR_FOLLOWER` from `OffsetsForLeaderEpoch` until
the replica rebuilds the classic prefix. Without a log line, a replica that
doesn't recover is invisible. The broker now logs at most one line per minute.

Assisted-by: Claude Sonnet 5.5
…s while the switch is pending [KC-870] (#904)

* fix(inkless:switch): answer OffsetsForLeaderEpoch on in-sync followers while the switch is pending [KC-870]

While the switch of a partition is pending, the metadata routing sends a
client to an alive ISR member, but only the leader answered
`OffsetsForLeaderEpoch`. A consumer whose position has a leader epoch
validates it after the leader epoch bump of the switch. On an in-sync
follower it got `NOT_LEADER_OR_FOLLOWER`, refreshed its metadata, got the
same follower, and read nothing until the controller committed the seal.

An in-sync follower now answers from its local classic log, as it already
does for `ListOffsets`. Its log holds every record below the leader's high
watermark, and a consumer validates a position at or below that offset.

A follower has no end offset for a leader epoch higher than the last one
in its log, such as the leader epoch of the switch. A consumer reads an
undefined end offset as a truncation and resets its position. The
follower keeps returning `NOT_LEADER_OR_FOLLOWER` for such an epoch.

Assisted-by: Claude Fable 5.2

* docs(inkless:switch): explain why a pending follower can answer a replica fetcher [KC-870]

The relaxed leader check of a pending partition doesn't depend on who
sends the request. A reader can't tell from the code that a replica
fetcher never gets an answer from a follower's log: the fetcher sends its
leader epoch to the leader of that epoch, and `Partition` rejects a
leader epoch that differs from its own.

Assisted-by: Claude Fable 5.2
…[KC-869] (#898)

* fix(inkless:metadata): prefer controller leader for managed replicas

For managed-replica diskless partitions (RF > 1, tiered partitions at
any RF, and switched partitions with a local classic prefix),
`InklessTopicMetadataTransformer` previously selected the client-facing
leader by hashing across candidate replicas. That hash came from the
unmanaged RF=1 design, where no real replica assignment existed to
balance load across brokers.

With managed replicas, KRaft already places replicas across racks and
balances leadership through preferred leader election. Hashing masked
the controller leader from clients and tooling without an AZ, so
preferred leader elections had no visible effect and leadership-skew
checks saw the hash distribution instead of KRaft leadership.

Pass `partition.leaderId()` into `selectLeaderForManagedReplicas` for
both `Metadata` and `DescribeTopicPartitions` responses, and select it
whenever it is in the candidate replica set (same-AZ replicas or
cross-AZ alive eligible replicas). When the controller leader isn't a
candidate (such as when it is in another AZ, offline, absent, or
outside the ISR during a local-prefix switch), fall back to
`selectByHash` for deterministic routing and cache locality. Non-replica
fallbacks and the untiered RF=1 path stay unchanged.

Assisted-by: Gemini 4 Neon

* test(inkless:kafkatest): pin follower rack in DeleteRecords tests

`DeleteRecordsAcrossTiersTest` previously ran with no `broker.rack`
and no `diskless_az`, relying on hash-based leader selection to route
clients to a follower. Because clients without an AZ now receive the
controller leader, both the follower read guard test and
`DeleteRecords` forwarding would land on the real KRaft leader and stop
exercising the follower paths.

Assign a distinct `broker.rack` to each broker in
`DeleteRecordsAcrossTiersTest`, add optional `client_id` and
`consumer_properties` hooks in `ConsolidationVerifier`, and pin
`diskless_az` to a follower's rack for the follower read guard
consumers (old and modern) and for cross-tier `DeleteRecords`. Update
the test docstrings to match.

Assisted-by: Gemini 4 Neon

* docs(inkless): document controller-leader preference for managed replicas

Update the AZ-alignment guide, consolidation guide, and
`DisklessDeleteRecordsForwarder` comment to reflect that
`InklessTopicMetadataTransformer` prefers the controller leader within
the chosen replica set and routes to a follower only when an AZ-aware
client stays on a same-AZ follower or the controller leader isn't an
eligible candidate.

Assisted-by: Gemini 4 Neon
…ffset in ListOffsets [KC-865] (#900)

`ListOffsets` returns leader epoch 0 with every diskless offset, because
`FetchOffsetHandler` sets a placeholder epoch on each control-plane
result. On a switched partition, `ReplicaManager.lastOffsetForLeaderEpoch`
treats an epoch below `initialDisklessLeaderEpoch` as a classic epoch and
answers with an end offset at or below the seal. A client that keeps the
epoch of the `ListOffsets` response then sees a truncation when it
validates its position, and seeks back to the seal. librdkafka keeps that
epoch, and the Java consumer does if the application seeks with it.

On a 3-broker cluster, kcat (librdkafka 2.11.1) that starts at the log
end of a partition sealed at 20, and receives no record, reads offsets 20
to 49 again after the leader epoch bump that starts phase 2.

`DisklessFetchOffsetRouter` now replaces the placeholder on a switched
partition:

- An offset at or past the seal gets `disklessLeaderEpoch`, the epoch
  that a consumer fetch carries for the same offsets.
  `OffsetsForLeaderEpoch` answers that epoch with the diskless log end
  offset, so the client keeps its position.
- An offset below the seal gets no leader epoch, because the broker
  doesn't know its classic epoch. The client skips the validation.

Born-diskless partitions keep the placeholder, and a result from the
local log keeps the epoch of the local record.

## Testing

- `DisklessFetchOffsetRouterTest` covers LATEST, MAX_TIMESTAMP, EARLIEST,
  and a timestamp lookup on both sides of the seal, in phase 1 and
  phase 2, and a partition with a seal of 0.
- `ReplicaManagerInklessTest.testFetchOffsetLatestOnSwitchedPartitionReturnsAnEpochThatKeepsThePosition`
  sends `ListOffsets` and validates the returned epoch with
  `OffsetsForLeaderEpoch`.
- `InklessTopicTypeSwitcherClusterTest.testConsumerKeepsAPositionFromListOffsetsOnASwitchedPartition`
  runs on 3 brokers. A consumer seeks to the offset and epoch that
  `ListOffsets` returns, in phase 1 and in phase 2, and starts at that
  offset.
- Without the change to `DisklessFetchOffsetRouter`, the new router
  tests, the `ReplicaManagerInklessTest` test, and the cluster test fail.
- `DisklessFetchOffsetRouterTest` passes with 65 tests.
  `:core:checkstyleMain`, `:core:checkstyleTest`, and
  `:core:spotbugsMain` pass.

Assisted-by: Claude Opus 5.5
Assisted-by: Claude Fable 5.2
… or in phase 1 [KC-867] (#903)

* fix(inkless:switch): reject DeleteRecords while the switch is pending or in phase 1 [KC-867]

In phase 1 of the classic-to-diskless switch, `DeleteRecords` below the
seal advances the log start of the leader and returns success. The
followers left the classic fetcher at the seal, so they don't learn the
new log start. The metadata routing sends consumers to them, and they
keep serving the deleted records until phase 2.

On a 3-broker cluster, after `DeleteRecords` with offset 10 on a
partition sealed at 20, the leader had log start 10, both followers had
log start 0, and consumers in the zones of the followers read offset 0.

The broker now rejects `DeleteRecords` for a partition with
`INVALID_REQUEST` while its switch is pending or in phase 1, and deletes
nothing. The other partitions of the same request proceed. The window is
as long as the upload of the classic prefix, and the request works again
from phase 2 on. Kafka Streams, which purges its repartition topics with
`DeleteRecords`, sends a new request at its next purge interval after a
failure.

Making the request work in that window needs every replica to learn the
new log start without a fetch. The rejection needs none of that, and it
also covers a request that arrives before the leader initializes the
partition in the control plane.

Without `DeleteRecords`, nothing moves the log start in that window. For
a consolidating partition, `RemoteLogManager` doesn't expire remote
segments until the control plane stores the remote log start of the
partition (`reclaimFloorLogStartOffset`). On a 3-broker cluster, with two
segments in remote storage and `retention.ms` set to 1 second in phase 1,
the expiration task deferred 5 times in 25 seconds and the log start
stayed 0 on every replica. After phase 2 started, the same task moved the
log start of the leader to 30.

- `ReplicaManagerInklessTest` has new tests for a pending switch, for
  phase 1 with an offset below the seal, at the seal, past the seal, and
  with `HIGH_WATERMARK`, and for a request that mixes a classic partition
  with one in phase 1.
- `InklessTopicTypeSwitcherClusterTest.testDeleteRecordsIsRejectedUntilPhaseTwo`
  runs on 3 brokers. In phase 1 the request fails with
  `InvalidRequestException`, no broker moves its log start, and consumers
  in every zone read from offset 0. After phase 2 starts, the request
  returns low watermark 10.
- Without the change to `ReplicaManager`, the 7 new tests fail.
- `ReplicaManagerInklessTest` (320 tests), `ReplicaManagerTest` (129
  tests), and `InklessTopicTypeSwitcherClusterTest` (10 tests) pass.
  `:core:checkstyleMain`, `:core:checkstyleTest`, and
  `:core:spotbugsMain` pass. `make vale` reports no alerts.

Assisted-by: Claude Fable 5.2

* docs(inkless:switch): document a DeleteRecords that arrives right before the switch [KC-867]

The leader rejects `DeleteRecords` from its own metadata. A request that
the leader receives before it applies the record that starts the switch
is a request for a classic partition, so the leader deletes the records.
The leader then proposes the seal as soon as its high watermark equals
its log end offset, without waiting for the followers to report the new
log start.

On a 3-broker cluster, with the request sent right before the switch,
the leader accepted it in 3 of 4 runs. Every replica ended with log
start 10, and the client got `TimeoutException` after 60 seconds. In the
fourth run the leader rejected the request.

The switch doc now states both effects, a request that times out and a
follower that isn't guaranteed to have the new log start, and tells the
operator not to send `DeleteRecords` right before a switch.

Assisted-by: Claude Fable 5.2

* test(inkless:switch): wait for phase 2 on every broker before the delete [KC-867]

`testDeleteRecordsIsRejectedUntilPhaseTwo` waited for phase 2 with
`waitForClassicPrefixInRemoteStorage`, which reads the phase from one
broker through the admin client. The leader rejects `DeleteRecords` until
its own metadata shows phase 2, and the admin client doesn't retry
`INVALID_REQUEST`. So the delete could fail if that broker applied the
phase 2 record before the leader did.

The test now waits until the metadata view of every broker shows phase 2
before it sends the delete.

Assisted-by: Claude Fable 5.2

* test(inkless:switch): fix the prose lint alerts in a test comment [KC-867]

The `Inkless Vale` workflow reported two alerts on the comment that the
previous commit added to `testDeleteRecordsIsRejectedUntilPhaseTwo`:
`admin` as a word, and `INVALID_REQUEST` without backticks. The comment
now names the `Admin` client and puts the error code in backticks.

Assisted-by: Claude Fable 5.2

* fix(inkless:switch): reject DeleteRecords for a switch that starts after the first check [KC-867]

`ReplicaManager.deleteRecords` reads the metadata three times: for the
switch check at its start, to classify the partitions, and to decide
which partitions skip the wait for the followers. The record that starts
the switch can arrive between these reads, and a review found two
outcomes:

- The classification sees a pending switch that the first check didn't.
  It handled the partition as a local delete, and because the topic now
  looked like a consolidating diskless topic, the request returned
  success at once while the followers still had their old log start.
- The classification sees a classic partition, and the topic looks like a
  consolidating diskless topic by the time the local delete finishes. The
  request skipped the wait for the followers.

`deleteRecords` now rejects a pending switch at the classification with
`INVALID_REQUEST`. Only a partition that the request classified as
diskless skips the wait for the followers, so a delete of a classic
partition waits for them as before. The method also wraps the response
callback once and no longer calls itself for the partitions it doesn't
reject.

The comment on the check said that phase 2 sets the remote log start in
the control plane. `ConsolidatedDisklessLogPruner` stores it once the
classic prefix is uploaded, so the comment now says that remote retention
waits while the leader still uploads the prefix.

## Testing

- `ReplicaManagerInklessTest` has two new tests, one for each outcome:
  `testDeleteRecordsIsRejectedWhenTheSwitchStartsAfterTheFirstCheck` and
  `testDeleteRecordsOfAClassicPartitionWaitsForFollowersWhenTheSwitchStartsMeanwhile`.
  Both fail without the change to `ReplicaManager`.
- `ReplicaManagerInklessTest` (322 tests), `ReplicaManagerTest` (129
  tests), and `InklessTopicTypeSwitcherClusterTest` (10 tests) pass.
  `:core:checkstyleMain`, `:core:checkstyleTest`, and
  `:core:spotbugsMain` pass. `make vale` reports no alerts.

Assisted-by: Claude Fable 5.2
… consolidating partition [KC-848] (#907)

* fix(inkless:consolidation): don't supplement an empty local read of a consolidating partition [KC-848]

A consumer fetch of a consolidating partition can come back from the
local log with no records and no error, although the log holds data at
the fetch offset. This happens when an earlier partition uses up the
request byte budget, or when the next batch doesn't fit the remaining
budget. buildConsolidationSupplementFetchInfos anchored the supplement
for such a read at the local log end offset, so the exhaustion guard
passed and the response started at the log end offset. The consumer
then skipped [fetchOffset, logEndOffset) without an error.

The helper now anchors an empty read at the fetch offset, so the guard
drops the supplement and the consumer fetches again from its own
offset. The helper also skips a partition whose local read returns a
preferred read replica or a remote storage redirect. This covers
DelayedFetch.onComplete, which has none of the inline path's guards.

fetchParamsWithNewMaxBytes still gives every leg the full byte budget.
That behavior is out of scope here.

## Test plan

- Rewrite the test that pinned the old behavior to expect no supplement
  for an empty read below the log end offset.
- Add DelayedFetch tests for a mixed request with an empty local read,
  a preferred read replica, and a remote storage redirect. They fail
  without the fix.
- Run DelayedFetchTest, ReplicaManagerInklessTest, and
  ReplicaManagerTest.

Assisted-by: Claude Sonnet 5.5
Assisted-by: Claude Opus 5.5

* fix(inkless:consolidation): skip the supplement for a local read without a complete batch

The previous commit anchored an empty local read at the fetch offset.
Routing adds a partition only when its fetch offset is below the log
end offset, so the exhaustion guard always dropped that read. The
outcome was correct, but the code read as if an empty read gets a
supplement starting at the fetch offset.

buildConsolidationSupplementFetchInfos now computes a start offset only
from the last complete batch of the local read. A read without one gets
no supplement, whatever offset routing admits.

## Test plan

- Rename the test for an empty read at the log end offset to
  testBuildConsolidationSupplementFetchInfosSkipsEmptyLocalReadAtLogEndOffset.
  It now expects no supplement.
- Run DelayedFetchTest, ReplicaManagerInklessTest, and
  ReplicaManagerTest: 467 tests pass.

Assisted-by: Claude Opus 5.5
…kafka (#909)

* [aiven] ci: skip CI Complete on forks

CI Complete publishes Gradle Build Scans to develocity.apache.org with a
secret that only apache/kafka has. On aiven/inkless every run fails with
"rejected the request due to authentication being required".

Run the jobs only when github.repository is apache/kafka, as
docker_promote.yml and docker_scan.yml already do.

Assisted-by: Claude Sonnet 5.5

* [aiven] ci: skip Pull Request Reviewed on forks

Pull Request Reviewed saves the PR number for pr-linter.yml, whose job
is disabled (if: false). On aiven/inkless it runs on every review and
only produces an artifact that nothing reads.

Run the job only when github.repository is apache/kafka. The workflow
file stays unchanged otherwise, to keep the diff with upstream small.

Assisted-by: Claude Sonnet 5.5
…thesis SDK (#887)

`inkless_produce_consume_test.py` imports `antithesis.assertions` at
module level. Only the Antithesis driver image installs the SDK, so in
the ducker image ducktape fails to import the module, logs a warning,
finds no tests in it, and skips it. The nightly Inkless system tests
have passed without running this test.

Outside Antithesis the test now falls back to no-op assertions. Each
Antithesis assertion is followed by a plain `assert` on the same
condition, so the test still fails on a mismatch. The Antithesis
driver keeps using the real SDK.

Assisted-by: Claude Opus 5.5
…r's local log starts past it [KC-872] (#905)

* fix(inkless:switch): rebuild a follower below the seal when the leader's local log starts past it [KC-872]

In phase 2 of the classic-to-diskless switch, a follower whose log ends
below the seal stays on the classic fetcher and rebuilds from remote
storage. If local retention moved the leader's local log start past the
seal, the rebuild failed on every retry. The replica's log stayed empty,
the controller kept the replica in the ISR, and a consumer that the
metadata routing sent to it read no records.

`TierStateMachine` used the `lastClassicLeaderEpoch` lookup only if the
leader's local log starts at or below the seal. Otherwise it sent
`OffsetsForLeaderEpoch` for the epoch before `disklessLeaderEpoch` to the
leader. The leader treats that epoch as a diskless epoch and answers
with the requested epoch and the diskless end offset, which a consumer
needs to validate its position. No remote segment holds that epoch, so
the segment lookup threw `RemoteStorageException`.

If the source's local log starts past the seal, the record before it is
a consolidated record. Consolidation writes every record from the seal
on in `disklessLeaderEpoch`, which is the epoch the source reports for
its local log start. The tier-state machine now looks up the remote
segment in that epoch and doesn't send the request.

- `ReplicaManagerInklessTest`:
  `testTierStateMachineRebuildsFromSourceWhoseLocalLogStartsPastTheSeal`.
- `InklessTopicTypeSwitcherClusterTest`:
  `testAddedReplicaRebuildsWhenLeaderLocalLogStartsPastSeal`. The class
  now runs with `log.retention.check.interval.ms=500`, so local
  retention runs within a test.
- Both tests fail without the change to `TierStateMachine`.

Assisted-by: Claude Fable 5.2

* fix(inkless:switch): validate a follower fetch at the leader's local log start when it's past the seal

A follower that rebuilds its log from a leader whose local log starts
past the seal fetches next at the leader's local log start. If the
leader has local records from there on, it returns them, and the
follower hands off to consolidation.

An idle leader has none. Local retention rolls its last segment, the
remote log manager uploads it, and the next retention check deletes it.
The local log is then an empty active segment past the seal. The
follower's fetch is at the leader's log end offset, so the leader
validates it as a fetch at the seal. The read at the seal throws
`OffsetOutOfRangeException`, because no local segment holds that
offset. The follower gets `OFFSET_OUT_OF_RANGE`, keeps its offset, and
retries once per second on the classic fetcher until the partition
gets a new record.

The leader now validates the fetch at its local log start if that
offset is past the seal. In phase 1 and on a leader whose log ends
below the seal, the local log starts at or below the seal, so the
validation offset stays the seal.

A reviewer found the case on the pull request.

## Testing

- `ReplicaManagerInklessTest`:
  `testFollowerFetchPastSealSucceedsWhenLeaderLocalLogStartsPastSeal`.
- `InklessTopicTypeSwitcherClusterTest`:
  `testAddedReplicaRebuildsWhenLeaderLocalLogStartsPastSeal` now runs
  with an idle leader too, and it checks that the added replica leaves
  the classic fetcher.
- Without the change to `ReplicaManager`, the unit test fails with
  `OFFSET_OUT_OF_RANGE`, and the idle variant of the cluster test fails
  because the classic fetcher still holds the partition.

Assisted-by: Claude Fable 5.2
…og pruner [KC-878] (#908)

In phase 1 of the classic-to-diskless switch, remote retention can move the log start of the leader after the leader uploads the classic prefix, if the controller hasn't committed phase 2 yet. The followers keep their log start. With this change `ConsolidatedDisklessLogPruner` skips a partition in phase 1, so remote retention waits for phase 2.

## Problem

For a consolidating partition, `RemoteLogManager` doesn't expire remote segments until the control plane stores the remote log start of the partition. The first prune of `ConsolidatedDisklessLogPruner` stores that value. For a switched partition, the pruner sends this prune as soon as remote storage ends at `seal - 1`, and it skips only a partition whose switch is pending. A partition in phase 1 qualifies once the leader uploads the classic prefix.

The leader then asks the controller to start phase 2. Until the controller commits that record, the partition stays in phase 1: the followers stopped fetching at the seal and serve the classic prefix from their local logs. If the pruner runs in that window, remote retention deletes the prefix on the leader and moves its log start, and the followers keep theirs.

### Example before this change

On a 3-broker cluster, a topic with replicas on brokers 1 and 2 holds 20 records and is sealed at offset 20. `retention.ms` is 1 second and the pruner runs every 2 seconds. The controller is stopped before the leader can upload the prefix, so phase 2 can't commit:

1. 1.5 seconds after remote storage becomes available, the leader has `highestOffsetInRemoteStorage=19`.
2. 6 seconds after, the leader has `logStartOffset=20` and the follower has `logStartOffset=0`. `classicPrefixInRemoteStorage` is false on both brokers.
3. 60 seconds after, the state is the same.

## Fix

The pruner skips a partition while `isClassicPrefixOnlyOnLocalDisks` is true, which covers the pending switch and phase 1. Nothing consolidates in phase 1, so the prune that the pruner now skips deletes no diskless batches. The first pruner run in phase 2 stores the remote log start, and remote retention runs from then on.

With the change, the same scenario keeps `logStartOffset=0` on both replicas for the 60 seconds of the check.

## Test plan

- `ConsolidatedDisklessLogPrunerTest.testRunOmitsSwitchedPartitionInPhaseOneWhenRemotePrefixEndsBeforeSeal` covers a partition in phase 1 whose remote storage ends at `seal - 1`. It fails without the change, because the pruner sends the prune.
- `testRunBootstrapsSwitchedPartitionWhenRemotePrefixEndsBeforeSeal` still passes: in phase 2 the same state sends the prune.
- On a 3-broker cluster with the controller running, the leader's log start moves from 0 to 20 about 4 seconds after `classicPrefixInRemoteStorage` becomes true, so remote retention still runs in phase 2.
- The cluster scenarios ran as temporary tests that stop the controller and watch the replicas for 60 seconds. They aren't part of this change.
- `./gradlew :core:checkstyleMain :core:checkstyleTest :core:spotbugsMain :core:test --tests "io.aiven.inkless.consolidation.*" --tests "kafka.server.InklessTopicTypeSwitcherClusterTest"` passes: 166 tests, 0 failures.

Assisted-by: Claude Fable 5.2
Check weekly for updates of the libraries that :storage:inkless declares.
Libraries shared with the rest of Kafka (Jackson, slf4j, JUnit, Scala) are
not in the allow list. Major updates are ignored and need a manual PR.

Assisted-by: Claude Sonnet 5.5
…ads [KC-859] (#906)

When `PostgresControlPlane` routes reads to a PostgreSQL standby, a
restarted or lagging standby can serve an older snapshot during node
replacement or switchover. Consumers fetching an offset valid on the
primary receive a false `OFFSET_OUT_OF_RANGE` and reset their offsets,
and consolidating fetchers call `listOffsets(LATEST)` against the same
stale standby and truncate their local log and high watermark backward.

Add an optional `inkless.control.plane.read.primary.*` pool and activate
standby protection when both `read.*` and `read.primary.*` are
configured:

- Route `listOffsets`, `getCrossTierLogStart`, and `getProducerState`
  directly to `readPrimaryDataSource` so staleness that `list_offsets_v1`
  can't signal never reaches callers. Keep `jobsDataSource` isolated
  when `read.primary.*` is absent.
- When `findBatches` receives above-high-watermark `OFFSET_OUT_OF_RANGE`
  from the standby, re-run the fetch against `readPrimaryDataSource`
  behind a fail-fast concurrency limiter
  (`standby.fallback.max.concurrent`, defaulting to 90% of
  `read.primary.max.connections`, at least 1) so confirmation and
  fallback bursts don't starve `listOffsets`, `getCrossTierLogStart`,
  and `getProducerState` sharing the same pool. Re-running the full
  fetch on primary lets `find_batches_v2` enforce `fetchMaxBytes`,
  per-partition limits, and the request-wide minimum-batch allowance in
  one pass with fresh watermarks. Skip below-LSO errors, which are
  monotonically expired, and return retriable `KAFKA_STORAGE_ERROR` for
  only the unconfirmed partitions when the limiter rejects or primary
  fails while preserving healthy standby responses for other partitions
  in the same fetch.
- Add `inkless.control.plane.read.primary.connection.string` to
  `InklessControlPlaneConfigs.RECONFIGURABLE_CONFIGS` and
  `DynamicInklessControlPlaneConfig` with the same runtime takedown
  semantics as the existing connection strings.
- Publish `FindBatchesPrimaryQueryTime`, `FindBatchesPrimaryConfirmRate`,
  `FindBatchesPrimaryOverrideRate`,
  `FindBatchesPrimaryConfirmFailureRate`, and
  `PrimaryReadLimitRejectedRate` on `PostgresControlPlaneMetrics`, and
  regenerate the config and metrics reference docs.

Testing

- `PostgresControlPlaneStandbyProtectionTest` exercises two PostgreSQL
  databases where the read database lags behind the primary, covering
  above-HWM override, genuine out-of-range confirmation, below-LSO skip,
  request-order `fetchMaxBytes` and zero-limit enforcement across both
  orderings, mixed-partition concurrency-limit rejection and primary
  failure, primary routing for `listOffsets`, `getCrossTierLogStart`,
  and `getProducerState`, and `read.*`-only non-fallback.
- `ConsolidationFetcherThreadTest` verifies with a real `UnifiedLog` that
  consolidation doesn't truncate or regress local `highWatermark` on
  `KAFKA_STORAGE_ERROR` or when `listOffsets` reads ahead from primary.
- Unit tests cover `read.primary.*` parsing, prefix validation, dynamic
  reconfiguration, `FindBatchResponse.kafkaStorageError()`, and the new
  metrics.

Assisted-by: Gemini 4 Neon

Co-authored-by: Cursor <cursoragent@cursor.com>
…call-level timeouts [KC-874] (#915)

* fix(inkless:s3): record call-level timeouts in S3 metrics

`MetricCollector.publish()` reads `CoreMetric.ERROR_TYPE` only from `ApiCallAttempt` child collections. Because `ApiCallTimeoutTrackingStage` wraps `ApiCallAttemptMetricCollectionStage` in the AWS SDK sync pipeline, an `ApiCallTimeoutException` never appears on an attempt child. When a call times out before an HTTP attempt starts (such as during a backoff or rate-limiter wait) or while an attempt is in flight, `configured-timeout-errors` stays at zero even though requests time out.

Have `MetricCollector` implement `ExecutionInterceptor` and register it on the S3 client in `S3ClientBuilder`. On `onExecutionFailure`, record `CONFIGURED_TIMEOUT` globally and per operation when the failure is an `ApiCallTimeoutException`. Attempt-level `ApiCallAttemptTimeoutException` failures stay handled by `publish()` without double counting.

Assisted-by: Gemini 4 Neon

* fix(inkless:s3): default S3 retry mode to standard and add s3.retry.mode

With a bounded `s3.api.call.timeout` (default 2000 ms), the AWS SDK `ADAPTIVE_V2` client-side token bucket can enter a self-sustaining lockout after S3 throttling. Once a throttling response sets `enabled = true` on `RateLimiterTokenBucket`, that flag never resets. If a throttling burst or a quiet period drops `fillRate` below concurrent request demand, callers subtract tokens into negative capacity and sleep in `RetryableStage2` past `apiCallTimeout`. Timed-out calls fail before sending an HTTP attempt, never refund their tokens, and never deliver the successful response required for CUBIC recovery, so the client stays stuck until broker restart. Current upstream AWS SDK v2 releases still queue timed-out sync waiters without skipping cancelled futures in `RateLimiterTokenBucket.doNotify()`.

`ADAPTIVE_V2` was enabled in #442 when `s3.api.call.timeout` defaulted to unbounded (`null`) and hot and cold reads shared one fetch client. Later changes split out a dedicated cold-path client (#562, which sees idle gaps between bursts that drag `fillRate` down via `2 * measuredTxRate`) and set the default `s3.api.call.timeout` to 2000 ms (#791), exposing the lockout cliff. AWS SDK Javadoc also cautions against `ADAPTIVE_V2` when predictable latency matters or a single client serves multiple resources, and upstream AWS SDK v2 now defaults to `STANDARD`.

Add `s3.retry.mode` (valid values `standard` and `adaptive_v2`, case-insensitive) to `S3StorageConfig`, wire it in `S3ClientBuilder`, and switch the default to `standard`. `STANDARD` keeps jittered exponential backoff and the SDK retry quota circuit breaker without the client-side rate limiter. Per-role overrides (such as `inkless.storage.fetch.s3.retry.mode`) work through the existing `InklessConfig` role layering.

Add `S3ThrottlingRecoveryTest` to verify concurrent fetches recover after `503 SlowDown` throttling with the default mode and that pre-attempt timeouts with `adaptive_v2` increment `configured-timeout-errors`.

Assisted-by: Gemini 4 Neon

* fixup! fix(inkless:s3): record call-level timeouts in S3 metrics

Assisted-by: Gemini 4 Neon
* chore(inkless:ci): add a single result job for branch rules

The matrix job name "JUnit tests Java ${{ matrix.java }}" is a template. A required status check needs the name that the job reports, so a rule with the template text never matches and the pull request waits forever. A rule with one name per Java version breaks when the matrix changes.

Add the "Inkless CI result" job. It needs validate, inkless-version-tag, and test, and always runs. It fails if any of them did not succeed, including a skipped or canceled job. A branch rule can require this one name.

Assisted-by: Claude Sonnet 5.5

* fixup! chore(inkless:ci): add a single result job for branch rules

Assisted-by: Claude Sonnet 5.5
…ion file (#922)

Since the Kafka 4.4 sync (#897), the clients tests load the generated
kafka-version.properties, so getInklessTag() returns the git-describe of
the build instead of "unknown". The upstream CI workflow fails
testInklessTagDefaultsToUnknownAndSuppressesSuffix on main.

Move the suffix logic into inklessTagSuffix(String), as kafkaVersion
already does for the version, and test it with the unknown, empty, and
real tag values.

## Testing

- `./gradlew :clients:test --tests AppInfoParserTest` passes with a real
  inkless tag baked into the build.
- checkstyle, spotless, spotbugs, and the public API checker pass for
  `:clients`.

Assisted-by: Claude Opus 5.5
…al read ends mid-batch [KC-876] (#911)

* fix(inkless:consolidation): skip the diskless supplement when the local read ends mid-batch [KC-876]

A byte-limited local read of a consolidating partition can end inside a
batch. The batch iterator drops that partial tail, so the supplement
starts at the partial batch's base offset. The merge still keeps the
partial bytes, and the response holds a truncated batch in front of the
diskless batches. The consumer reads the partial header, runs into the
diskless bytes, and fails the CRC check.

The local log isn't frozen at the seal, because the consolidation
fetcher keeps appending to it. The log end offset captured at routing
can therefore be stale, which lets the exhaustion guard pass.

Skip the supplement when the complete batches don't account for all
local bytes. The partial batch then stays the last thing in the
response, and the consumer re-fetches from the last complete batch.

Testing

Add a `ReplicaManagerInklessTest` case that ends the local read inside
a batch past the stale log end offset. The test fails without the guard.

Assisted-by: Claude Sonnet 5.5

* fix(inkless:consolidation): scan the local read once when building the supplement [KC-876]

The batch-boundary check added a second pass over each local read, on top
of the `lastBatch()` walk. For a file-backed read, every pass costs a
channel read per batch, even when no supplement can run.

Find the last batch and total the complete bytes in one pass. Run the pass
only after the cheap checks (usable local read, remaining byte budget)
leave a supplement possible.

Testing

Run `ReplicaManagerInklessTest` and `DelayedFetchTest` with no failures.

Assisted-by: Claude Sonnet 5.5

* test(inkless:consolidation): pin the single-pass supplement scan and cover FileRecords [KC-876]

Skip the scan of a local read that is empty, and cover the behavior
that the previous commit left unpinned.

Add a `FileRecords` test that cuts the read inside a batch body and
inside a batch header, because production local reads return
`FileRecords` and `FileLogInputStream` handles each cut separately.
Add a test that spies on `batches()` to assert zero scans when the
budget is exhausted or the read is redirected, and one scan when the
read is eligible.

Testing

Run `ReplicaManagerInklessTest` and `DelayedFetchTest` with no failures.
The new tests fail when the scan runs eagerly or ignores the batch
boundary.

Assisted-by: Claude Sonnet 5.5
…n integration tests (#921)

* fix(inkless:test): wait for online replicas before switching empty topic in InklessTopicTypeSwitcherClusterTest

`testAlterDisklessSwitchRejectsReArmAndNonLowerSealOnCommittedSwitch()` created a 3-replica classic topic, called `TopicMetadataProbe.awaitVisible(admin, topic)`, and immediately flipped `diskless.enable=true` without producing records first. Because `TopicMetadataProbe.awaitVisible` probes only one broker, it can return as soon as a follower applies the `CreateTopics` delta while the partition leader has not yet applied it.

When that happens, the leader receives topic creation and `CLASSIC_TO_DISKLESS_SWITCH_PENDING` (`-2`) in a single coalesced metadata delta with `existingPartition = None` and no local log on disk. `ReplicaManager.applyLocalLeadersDelta()` then hits its missing-log guard (which prevents a leader with a lost local disk from sealing at offset 0), skips `makeLeader` and `registerPartition`, and leaves the seal stuck at `-2` until `waitForSealOffset` times out.

Wait until every broker hosts the partition as an online partition before calling `incrementalAlterConfigs(diskless.enable=true)`.

Assisted-by: Gemini 4 Neon

* fix(inkless:test): wait for topic metadata propagation in InklessControlPlaneMigrationLockClusterTest

`InklessControlPlaneMigrationLockClusterTest.createTopics()` called `admin.describeTopics(List.of(TOPIC_NAME))` immediately after `admin.createTopics(...)` returned. Because `createTopics` completes as soon as the controller commits the topics, the broker serving the follow-up `describeTopics` request may not have applied the metadata delta yet, causing flaky `UnknownTopicOrPartitionException` failures in CI.

Read the topic ID directly from `CreateTopicsResult.topicId(TOPIC_NAME)` instead of calling `describeTopics`, and wait until both created topics appear in every broker's metadata cache before returning.

Assisted-by: Gemini 4 Neon

* fix(inkless:test): await topic config visibility after createTopics in InklessUntieredDisklessMigrationTest

`testUntieredTopicKeepsWorkingWhenConsolidationIsEnabled()` called `admin.describeConfigs` for `born-consolidating` immediately after `admin.createTopics(...).all().get()` returned. Because broker metadata updates asynchronously after the controller commits a topic, a broker serving `describeConfigs` may not yet see the new topic and fail with `UnknownTopicOrPartitionException`.

Replace the unguarded `describeConfigs` call with `TopicMetadataProbe.awaitValue`, matching the rest of the Inkless integration suite.

Assisted-by: Gemini 4 Neon
… fallback [KC-858] (#910)

When a PostgreSQL read replica restarts or becomes unreachable during a
switchover, `findBatches` calls against `readDataSource` stall up to the
pool or socket timeout and fail with `UNKNOWN_SERVER_ERROR` until DNS
failover completes.

Add `StandbyCircuitBreaker` when both `read.*` and `read.primary.*` are
configured:

- Classify standby connectivity and timeout failures across the cause,
  `nextException`, and suppressed chains (`08*`, `57P01`, `57P02`,
  `57P03`, `SQLTransientConnectionException`, `SocketTimeoutException`,
  `ConnectException`, `UnknownHostException`), excluding query and
  serialization errors (`40001`, `40P01`).
- Fall back immediately to `primaryReadJooqCtx` through the fail-fast
  concurrency limiter on every standby connectivity failure (including
  failures before reaching the trip threshold) and while `OPEN`,
  returning per-partition retriable `KAFKA_STORAGE_ERROR` when the
  limiter rejects or the primary query throws.
- Trip `CLOSED -> OPEN` after `standby.circuit.breaker.failure.threshold`
  (default `3`) consecutive failures, soft-evict idle standby pool
  connections so recovery resolves fresh DNS, and probe the standby with
  `SELECT 1` on a daemon thread every
  `standby.circuit.breaker.probe.interval.ms` (default `10000`) using
  fixed-delay scheduling. Close on the first successful probe and bump a
  generation counter so late in-flight failures from an earlier outage
  cannot re-trip the recovered circuit.
- Publish `StandbyCircuitOpen` (CAS-detached on `close()` so rebuilt
  control planes do not clobber each other's gauge),
  `StandbyFallbackRate`, and `StandbyFallbackFailureRate` on
  `PostgresControlPlaneMetrics`, reusing `FindBatchesPrimaryQueryTime`
  and `PrimaryReadLimitRejectedRate`, and regenerate the config and
  metrics reference docs.

Testing

- `StandbyCircuitBreakerTest` verifies failure classification, cycle
  safety, `CLOSED -> OPEN -> CLOSED` transitions, soft eviction,
  stale-generation protection, rebuild-safe gauge detachment, and
  non-blocking `close()`.
- `PostgresControlPlaneStandbyProtectionTest` exercises a local TCP
  proxy in front of Testcontainers PostgreSQL to verify pre-trip
  fallback, tripping open, bypassing the dead standby while open,
  concurrency-limit rejection and primary failure returning
  per-partition `KAFKA_STORAGE_ERROR`, and automatic recovery via the
  background `SELECT 1` probe.
- `PostgresControlPlaneConfigTest` and `PostgresControlPlaneMetricsTest`
  verify the new config defaults, ranges, and metrics.

Assisted-by: Gemini 4 Neon

Co-authored-by: Cursor <cursoragent@cursor.com>
…#923)

* ci(inkless): fix Gradle caching, add PR cancellation, and shard tests

Inkless CI wall-clock p50 grew from 30 minutes to over 50 minutes because
two issues compounded each other:

- `validate` ran `generateJooqClasses` before `setup-gradle`, creating
  `~/.gradle` first and causing `setup-gradle` to skip cache restoration
  (0.16% build-cache hit rate). It also omitted `-PcommitId`, busting
  downstream build-cache keys on every commit, and both `validate` and
  `test` passed undefined `inputs.gradle-cache-*` values so every PR wrote
  1-2 GB into the 10 GB repository cache pool.
- `test` ran seven `./gradlew` invocations serially with
  `-PmaxParallelForks=2`, and all heavy cluster test classes serialized on
  one fork while the other fork sat idle.

Fix both and eliminate redundant runs:

- Add `concurrency` cancellation for pull requests so superseding pushes
  stop in-flight runs.
- Drop `ready_for_review` from `pull_request` types and remove the unused
  `is-draft` step: draft PRs already run the full workflow, so switching
  a PR to ready re-ran the same SHA.
- Move JOOQ generation and verification into a parallel `jooq-check` job
  (added to `Inkless CI result`'s `needs`) so `validate` starts with an
  empty `~/.gradle` and restores caches cleanly.
- Set `gradle-cache-read-only: ${{ github.ref != 'refs/heads/main' }}` and
  pass `-PcommitId=xxxxxxxxxxxxxxxx` in `validate`.
- Add `-PexcludeTests` support in `build.gradle` and split `test` into
  four parallel shards per Java version (`storage-inkless`, `core-switch`,
  `core-consolidation`, and catch-all `core-other-and-kafka`), raising
  default `-PmaxParallelForks` to 3 and dropping the duplicate
  `:storage:inkless:integrationTest` call.

Assisted-by: Gemini 4 Neon

* ci(inkless): pin inklessTag in validate and test for build-cache stability

`determineInklessTag()` falls back to `git describe --tags --match
inkless-* --always --dirty`, which changes on every commit and feeds
`inputs.property "inklessTag"` on every `createVersionFile` task. Pass
`-PinklessTag=unknown` alongside `-PcommitId=xxxxxxxxxxxxxxxx` in both
`validate` and `test` so version files and downstream JARs keep stable
cache keys across commits.

Assisted-by: Gemini 4 Neon
…ervals (#924)

* test(inkless): clone a pre-migrated Postgres template database per test

Every Postgres-backed test method creates a blank database and runs the
full Flyway migration chain from scratch, spending ~1.2s per test in
DDL setup (`PostgresControlPlaneTest` runs 114 migrations in 146s;
`WriterPropertyTest` runs 100 in 131s).

In `InklessPostgreSQLContainer`, create and migrate an
`inkless_migrated_template` database once per container, lock it with
`IS_TEMPLATE true ALLOW_CONNECTIONS false`, and clone per-test
databases via `CREATE DATABASE ... TEMPLATE`. Add `createEmptyDatabase`
for tests that migrate to a specific historical Flyway version
(`BatchesPlanRegressionTest` and
`ListOffsetsTimestampScanBenchmarkTest`).

Assisted-by: Gemini 4 Neon

* test(inkless): lower RLM and consolidation poll intervals in cluster tests

The four heaviest tiered and consolidated cluster test classes configure
5-second remote log manager and consolidation cleanup poll intervals,
stretching every tiering, WAL-pruning, and local-retention wait.

Lower `remote.log.manager.task.interval.ms` from 5000 ms to 1000 ms in
`InklessTopicTypeSwitcherClusterTest`,
`InklessConsolidatedDisklessTopicsTest`,
`InklessUntieredDisklessMigrationTest`, and
`InklessConsolidatedDisklessReassignmentTest`. Lower
`consolidation.cleanup.interval.ms` to 1000 ms in
`InklessConsolidatedDisklessTopicsTest` and adjust its reclaim-cycle
wait from 15s to 5s (5 cycles at 1s instead of 3 at 5s).

Assisted-by: Gemini 4 Neon
#928)

The Kafka 4.4 sync moved `ByteBufferInputStream` to
`org.apache.kafka.common.utils.internals`. Plugin 1.1.1 still references
the old class, so brokers in the ducker and Inkless images exit at startup
with `NoClassDefFoundError`. The Gradle dependency already moved to 1.2.1,
which supports Kafka 4.4. This change aligns both Dockerfiles with it.

Assisted-by: Claude Opus 5.5
…essing EARLIEST [KC-879] (#916)

* fix(inkless:switch): keep DeleteRecords below the log start from regressing EARLIEST [KC-879]

`EARLIEST` falls back to the WAL log start until the control plane stores
the first cross-tier value. A DeleteRecords request below the log start
sends a lower offset, and storing it moved `EARLIEST` below the first
stored batch.

The control plane now clamps the first cross-tier value to the log start,
so a delete below the log start keeps `EARLIEST` unchanged. The
`advance_cross_tier_log_start_v1` function in `V33` does the same in
Postgres.

Testing

`AbstractControlPlaneTest` covers an advance below the WAL start before
the first prune and a delete below the classic log start on a switched
log.

Assisted-by: Claude Sonnet 5.5

* chore(inkless:control-plane): regenerate jOOQ classes for schema version 33 [KC-879]

The `V33` migration raises the schema version from 32 to 33. The CI check
compares the committed jOOQ classes with a fresh `generateJooqClasses`
run, and it failed because the committed classes still said version 32.

Testing

`generateJooqClasses` ran as part of
`./gradlew :storage:inkless:test --tests '*InMemoryControlPlaneTest' --tests '*PostgresControlPlaneTest'`.
The diff changes only the `schema version` line in 120 files.

Assisted-by: Claude Sonnet 5.5

* refactor(inkless:control-plane): trim the comments added for KC-879

Several comments restated the code or each other. The Java, SQL, and
Scaladoc comments all explained the same `EARLIEST` fallback, and the
test comment repeated the test name.

Testing

`InMemoryControlPlaneTest` and `PostgresControlPlaneTest` pass, and
`make vale` reports no alerts.

Assisted-by: Claude Sonnet 5.5

* docs(inkless:control-plane): drop the outdated reason for reporting a 0 cross-tier log start [KC-879]

The comment in `CrossTierLogStartReporter.enqueue` said a report of `0`
must reach the control plane, or `EARLIEST` would show the pruned
`log_start_offset`. That reasoning no longer holds. The first prune sets
`remote_log_start_offset = log_start_offset`, and the control plane never
stores a first value below the log start.

Testing

`CrossTierLogStartReporterTest` passes and `make vale` reports no alerts.

Assisted-by: Claude Sonnet 5.5
…#926)

* ci(inkless): tighten upstream CI triggers, drop Vale ready_for_review, and build edge tarball once

Three repo-wide workflow inefficiencies waste runner capacity and add
unnecessary cache entries:

- `ci.yml` matches `inkless-*` on push without excluding release-prep or
  sync branches (unlike `inkless.yml`), and does not cancel superseded
  push runs on `main`, letting burst merges run multiple 450-minute
  upstream builds in parallel.
- `inkless-vale.yml` triggers on `ready_for_review` even though it
  already runs on draft PRs, re-running on the same SHA.
- `inkless-edge.yml` runs `make build_release` twice (on `amd64` and
  `arm64`) for an architecture-independent Kafka tarball, and writes
  Gradle caches from both architectures into the 10 GB repository pool.

Update all three workflows:

- Scope `ci.yml` push triggers to `inkless-4.*` with `!inkless-4.*-*`,
  and enable `cancel-in-progress: true` keyed by workflow, ref, and
  event name so pushes cancel superseded pushes without canceling
  scheduled or manual runs.
- Drop `ready_for_review` from `inkless-vale.yml`.
- Extract `build-dist` in `inkless-edge.yml` to build the Kafka
  distribution once on `ubuntu-latest` with a read-only Gradle cache,
  upload it as a 1-day artifact, and share it across both native Docker
  build jobs.

Assisted-by: Gemini 4 Neon

* ci(inkless): match release branches with inkless-[0-9]+.[0-9]+

GitHub Actions branch filters match the full branch name and support
`[0-9]+`. Using `inkless-[0-9]+.[0-9]+` in both `ci.yml` and
`inkless.yml` stays future-proof beyond Kafka 4.x and excludes
release-prep and sync branches without a separate negation rule.

Assisted-by: Gemini 4 Neon
giuseppelillo and others added 4 commits December 3, 2026 13:31
… tests (#917)

The switch test helpers ran `kafka-topics --describe` on the first running
broker. When that broker is the one a network partition cuts off, the leader
check can't get an answer: `--describe` also sends
`ListPartitionReassignments` to a random unfenced broker, and the cut-off
broker is still unfenced. If the pick is a broker the query node can't reach,
the command waits out the 60 s client timeout. Two such attempts used up the
120 s budget of `_wait_for_all_partitions_have_leaders` in the nightly run of
`test_fault_before_control_plane_init` with `fault=leader_sigkill`, although
every partition had a leader 7 s after the kill. Querying from another broker
doesn't help, because it can draw the cut-off broker.

The leader, ISR, and full-ISR waits now run `kafka-topics` from a host of the
isolated controller quorum. The network partitions in these tests list only
brokers, so that host reaches every broker. Without an isolated quorum, the
helpers fall back to the first running broker.

Assisted-by: Claude Opus 5.5
…l with tests (#933)

* fix(inkless:ci): limit main test cache writes to core-other-and-kafka

`setup-gradle` runs `cache-cleanup: on-success`, so each test shard on
`main` prunes jars it did not touch and uploads its own ~267-507 MB
`gradle-dependencies` archive. Four shards writing on `main` pushed
`main`'s caches alone to 6.5 GB against GitHub's 10 GB repo cap.

Restrict `test` cache writes on `main` to `core-other-and-kafka` (which
touches all six tested modules) so only `validate` and that shard write
caches on `main`, while other shards and all PRs stay read-only.

Assisted-by: Gemini 4 Neon

* chore(inkless:ci): run validate and test shards in parallel

`validate` is cache-read-only on pull requests, so waiting for it via
`needs: validate` provides no build-cache reuse for PR test shards while
adding ~5 minutes to PR wall-clock time. `Inkless CI result` still
requires both `validate` and `test` to succeed.

Drop `needs: validate` from `test` so `validate` and the test shards run
in parallel, cutting PR wall-clock time from ~14-15m to ~8-9m.

Assisted-by: Gemini 4 Neon
…al on DeleteRecords [KC-880] (#927)

* fix(inkless:switch): advance the leader's local log start past the seal on DeleteRecords [KC-880]

On a switched consolidating partition, DeleteRecords with an offset above
the seal cut the leader's local log only at the seal. The leader's local
log also holds the consolidated range from the seal up to its high
watermark, and its consumer fetch is gated only by the local log start.
The leader kept serving the deleted range while ListOffsets(EARLIEST)
and every follower already rejected it.

The local leg now deletes up to the requested offset, capped at the
local high watermark and never below the seal. A lagging leader stops
at its high watermark, and its consolidation fetch later resets to the
cross-tier earliest. Without consolidation the local log ends at the
seal, so the behavior there doesn't change.

## Test plan

- Add `ReplicaManagerInklessTest` cases for a delete past the seal and
  for a delete past the leader's local high watermark. Both fail
  without the fix.
- Run the full `ReplicaManagerInklessTest` suite: 297 tests pass.

Assisted-by: Claude Opus 5.5

* test(inkless:switch): cover the lagging leader's reset after DeleteRecords past the seal [KC-880]

A leader whose local high watermark is below the DeleteRecords offset
cuts its local log at the high watermark, past the seal. Its next
consolidation fetch has to reset it to the cross-tier earliest. Nothing
exercised the endpoint with a local log start between the seal and the
cross-tier earliest, or the fetcher reset that follows.

## Test plan

- Add a `DisklessLeaderEndPointTest` case for that state: the endpoint
  returns `OFFSET_OUT_OF_RANGE` without consulting RLMM.
- Add a `ConsolidationFetcherThreadTest` case that drives the real
  fetcher thread and endpoint through one `doWork()` and checks
  `truncateFullyAndStartAt` at the cross-tier earliest.

Assisted-by: Claude Opus 5.5
On 4.3, `ConfigurationControlManager#incrementalAlterConfig`,
`incrementalAlterConfigs`, and `legacyAlterConfigs` take a `forwarded`
flag. The tests added by #899 used the main signatures, so they now pass
`false`.

The #927 test in `ConsolidationFetcherThreadTest` mocks `LogConfig`. On
main, an earlier main-only change already imports it, so the cherry-pick
adds the import.

After these picks, `kafka.server.ReplicaManager` on 4.3 is too big for
SpotBugs, and `:core:spotbugsMain` fails with `SKIPPED_CLASS_TOO_BIG`.
The exclude filter skips that pattern for `ReplicaManager` only, as
`inkless-4.1` has done since 0.51.

Assisted-by: Claude Opus 5.5
Upstream 4.4 adds the `:api-checker` included build, and the root
build script loads its plugin. Gradle compiles that plugin with the
running JDK, so its bytecode differs between JDK 25 and JDK 17. The
classpath of generateJooqClasses then changes, and Gradle reruns the
task under JDK 17 in the CI docs step. JDK 17 drops the "this-escape"
warning from the generated @SuppressWarnings annotations, which leaves
the committed jOOQ sources dirty.

The docs targets read the committed jOOQ sources, and CI checks those
sources in a separate JDK 25 step, so `make docs` skips the generation.

Assisted-by: Claude Opus 5.5
@gqmelo
gqmelo marked this pull request as draft December 3, 2026 14:01
@gqmelo
gqmelo marked this pull request as ready for review December 3, 2026 15:19
@jeqo
jeqo merged commit b70b8ba into inkless-4.3 Dec 4, 2026
14 checks passed
@jeqo
jeqo deleted the inkless-4.3-0.53 branch December 4, 2026 05:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

0