8000 feat(inkless:metadata): add classicPrefixInRemoteStorage flag [KC-580] by jeqo · Pull Request #824 · aiven/inkless · GitHub
[go: up one dir, main page]

Skip to content

feat(inkless:metadata): add classicPrefixInRemoteStorage flag [KC-580] - #824

Merged
viktorsomogyi merged 1 commit into
mainfrom
jeqo/kc-580-classic-prefix-in-ts-field
Oct 13, 2026
Merged

viktorsomogyi merged 1 commit into
mainfrom
jeqo/kc-580-classic-prefix-in-ts-field

Conversation

@jeqo
@jeqo jeqo commented Oct 13, 2026
Copy link
Copy Markdown
Contributor

The two-phase classic-to-diskless switch (KC-576) tells phase 1 from phase 2 with one per-partition flag in KRaft metadata. This PR adds the field and its serialization. Nothing reads or writes the flag yet, so behavior does not change.

Changes

  • Add tag 103 on PartitionRecord and PartitionChangeRecord, next to the switch tags 100 to 102. Writers emit it only when the flag is true.
  • Add PartitionRegistration.classicPrefixInRemoteStorage, default false. It is part of the builder, toRecord, merge, diff, equality, and toString.
  • Keep the flag in merge when a change record has no tag 103, including a record with a negative seal. The controller rejects such a record once a seal is committed, and KC-586 extends that guard to every seal request after the flag is set.
  • Decode only the first payload byte: 1 is true and any other value is false. The decoder does not throw, so a bad payload cannot fail metadata replay or trigger the deletion of the local classic prefix. A new meaning needs a new field.

Test plan

  • InitDisklessLogFieldsTest pins the encoder and the decoder: the tag number, absent versus present, and which payload bytes read as true or false.
  • PartitionRegistrationTest covers the snapshot path with and without the other switch tags, and checks that merge keeps the flag for ISR, leader, seal, and negative-seal changes.
  • TopicsImageTest round-trips a partition with the flag through image records and through the serialized record format.

Rollout and follow-ups

  • A node that doesn't know tag 103 drops it when it writes a snapshot. No switch can start until every node runs this version. The rollout ticket for KC-576 covers that rule.
  • KC-582 adds the RPC that sets the flag. It also returns the flag in the DescribeTopicPartitions response and shows the phase in the switch tool.
  • KC-586 rejects every seal request once the flag is set.

The two-phase classic-to-diskless switch (KC-576) tells phase 1 from
phase 2 with one per-partition flag in KRaft metadata. This change adds
the field and its serialization. Nothing reads or writes the flag yet,
so behavior does not change.

The flag uses tag 103 on PartitionRecord and PartitionChangeRecord, next
to the switch tags 100 to 102. Writers emit it only when it is true, so
a cluster that never sets it writes the same records as before. An
absent tag means false for a new registration and "no change" for a
change record.

The decoder reads only the first payload byte: 1 is true and any other
value is false. It does not check the payload length and it does not
throw, so a bad payload cannot fail metadata replay or trigger the
deletion of the local classic prefix. A new meaning needs a new field,
not a new value of this one.

A change record without tag 103 keeps the flag, including a record that
carries a negative seal. The controller already rejects those records
once a seal is committed. KC-586 extends that guard to every seal
request after the flag is set.

Assisted-by: Claude Sonnet 5.5
@jeqo
jeqo requested a balanced review from Copilot October 13, 2026 09:52
Copilot AI left a comment
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

The flag is consistently propagated and its compatibility and serialization behavior are thoroughly tested.

0 open findings

What changed in this PR

Adds serialized metadata for tracking whether a partition’s classic prefix is in remote storage, without changing runtime behavior.

Changes:

  • Adds tagged-field encoding and defensive decoding for tag 103.
  • Propagates the flag through PartitionRegistration.
  • Adds merge, snapshot, serialization, and representation tests.
File Description
metadata/​src/​main/​java/​org/​apache/​kafka/​metadata/​InitDisklessLogFields.java Defines tag 103 and its codec.
metadata/​src/​main/​java/​org/​apache/​kafka/​metadata/​PartitionRegistration.java Stores, merges, serializes, and compares the flag.
metadata/​src/​test/​java/​org/​apache/​kafka/​metadata/​InitDisklessLogFieldsTest.java Tests tag encoding and decoding.
metadata/​src/​test/​java/​org/​apache/​kafka/​metadata/​PartitionRegistrationTest.java Tests registration behavior and persistence.
metadata/​src/​test/​java/​org/​apache/​kafka/​image/​TopicsImageTest.java Tests snapshot and wire-format round trips.
metadata/​src/​test/​java/​org/​apache/​kafka/​image/​node/​TopicImageNodeTest.java Updates the expected string representation.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@jeqo
jeqo marked this pull request as ready for review October 13, 2026 09:56
@jeqo
jeqo requested a review from viktorsomogyi October 13, 2026 09:56
@viktorsomogyi
viktorsomogyi merged commit 7ccb838 into main Oct 13, 2026
13 checks passed
@viktorsomogyi
viktorsomogyi deleted the jeqo/kc-580-classic-prefix-in-ts-field branch October 13, 2026 15:21
jeqo added a commit that referenced this pull request Oct 19, 2026
#824)

The two-phase classic-to-diskless switch (KC-576) tells phase 1 from
phase 2 with one per-partition flag in KRaft metadata. This change adds
the field and its serialization. Nothing reads or writes the flag yet,
so behavior does not change.

The flag uses tag 103 on PartitionRecord and PartitionChangeRecord, next
to the switch tags 100 to 102. Writers emit it only when it is true, so
a cluster that never sets it writes the same records as before. An
absent tag means false for a new registration and "no change" for a
change record.

The decoder reads only the first payload byte: 1 is true and any other
value is false. It does not check the payload length and it does not
throw, so a bad payload cannot fail metadata replay or trigger the
deletion of the local classic prefix. A new meaning needs a new field,
not a new value of this one.

A change record without tag 103 keeps the flag, including a record that
carries a negative seal. The controller already rejects those records
once a seal is committed. KC-586 extends that guard to every seal
request after the flag is set.

Assisted-by: Claude Sonnet 5.5
jeqo added a commit that referenced this pull request Oct 19, 2026
#824)

The two-phase classic-to-diskless switch (KC-576) tells phase 1 from
phase 2 with one per-partition flag in KRaft metadata. This change adds
the field and its serialization. Nothing reads or writes the flag yet,
so behavior does not change.

The flag uses tag 103 on PartitionRecord and PartitionChangeRecord, next
to the switch tags 100 to 102. Writers emit it only when it is true, so
a cluster that never sets it writes the same records as before. An
absent tag means false for a new registration and "no change" for a
change record.

The decoder reads only the first payload byte: 1 is true and any other
value is false. It does not check the payload length and it does not
throw, so a bad payload cannot fail metadata replay or trigger the
deletion of the local classic prefix. A new meaning needs a new field,
not a new value of this one.

A change record without tag 103 keeps the flag, including a record that
carries a negative seal. The controller already rejects those records
once a seal is committed. KC-586 extends that guard to every seal
request after the flag is set.

Assisted-by: Claude Sonnet 5.5
jeqo added a commit that referenced this pull request Oct 19, 2026
#824)

The two-phase classic-to-diskless switch (KC-576) tells phase 1 from
phase 2 with one per-partition flag in KRaft metadata. This change adds
the field and its serialization. Nothing reads or writes the flag yet,
so behavior does not change.

The flag uses tag 103 on PartitionRecord and PartitionChangeRecord, next
to the switch tags 100 to 102. Writers emit it only when it is true, so
a cluster that never sets it writes the same records as before. An
absent tag means false for a new registration and "no change" for a
change record.

The decoder reads only the first payload byte: 1 is true and any other
value is false. It does not check the payload length and it does not
throw, so a bad payload cannot fail metadata replay or trigger the
deletion of the local classic prefix. A new meaning needs a new field,
not a new value of this one.

A change record without tag 103 keeps the flag, including a record that
carries a negative seal. The controller already rejects those records
once a seal is committed. KC-586 extends that guard to every seal
request after the flag is set.

Assisted-by: Claude Sonnet 5.5
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.

3 participants

0