Conversation
4e56634 to
fc4d461
Compare
…ic to diskless Sealing is applied for both existing leaders and newly elected leaders.
fc4d461 to
4e41e53
Compare
jeqo
left a comment
There was a problem hiding this comment.
Looks solid. Just a minor suggestion.
| ): LogAppendInfo = { | ||
| val (info, leaderHWIncremented) = inReadLock(leaderIsrUpdateLock) { | ||
| if (_sealed) { | ||
| throw new NotLeaderOrFollowerException( |
There was a problem hiding this comment.
Worth noting here that this exception is used on purpose to force clients to refresh metadata and retry (as this is not explicit from the code)
There was a problem hiding this comment.
Right it's not very useful to request clients to refresh metadata. I've changed to BrokerNotAvailableException so that clients can retry but they are not forced to refresh the metadata.
There was a problem hiding this comment.
Right. It's not ideal, but that's the only way of keeping the client retrying until migration completes IIUC. Otherwise it fails at the client side, and they crash.
In the expected scenario, these round-trips should give enough room for migration to complete.
There was a problem hiding this comment.
There's also this aspect to consider: #533 (comment)
But I would not change the catch logic. So we either force a metadata refresh for every produce request or we accept that there will be failures in metrics during a migration. I lean towards the latter option.
AnatolyPopov
left a comment
There was a problem hiding this comment.
LGTM! Thanks, looks exactly as we discussed 👍 But leaving without approve for review from others.
There was a problem hiding this comment.
Pull request overview
This PR adds “sealing” behavior to prevent any further local-log writes when a topic transitions from classic to diskless, covering both existing leaders (at the time the config flips) and partitions that (re)become leaders while diskless is enabled.
Changes:
- Add sealing detection in
BrokerMetadataPublisherwhendiskless.enableflips totrue. - Add
ReplicaManager.sealTopicPartitionsplus logic to seal partitions during leader transitions for diskless topics. - Introduce a sealed flag in
Partitionthat rejects appends; add unit tests validating sealing behavior.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| core/src/main/scala/kafka/server/metadata/BrokerMetadataPublisher.scala | Detects classic→diskless via topic config delta and seals existing leaders. |
| core/src/main/scala/kafka/server/ReplicaManager.scala | Adds sealing helper and seals partitions when applying leader deltas for diskless topics. |
| core/src/main/scala/kafka/cluster/Partition.scala | Adds sealed state, seal API, and rejects appendRecordsToLeader when sealed. |
| core/src/test/scala/unit/kafka/server/metadata/BrokerMetadataPublisherTest.scala | Tests sealing is triggered on diskless.enable config change. |
| core/src/test/scala/unit/kafka/server/ReplicaManagerTest.scala | Tests sealTopicPartitions and sealing during applyDelta. |
| core/src/test/scala/unit/kafka/cluster/PartitionTest.scala | Tests Partition.seal behavior and append rejection. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
1. Add partition to set of changed partitions also when it's sealed 2. Log the sealing only when it actually happens 3. Fix test for correct follower->leader scenario
|
|
||
| // TODO: Add more fetch tests combinations, edge cases ara not covered yet. | ||
|
|
||
| @Test |
There was a problem hiding this comment.
Should we move these new tests into @Nested class Inkless instead?
There was a problem hiding this comment.
They already are, but the indentation of this test was wrong, fixed it now.
There was a problem hiding this comment.
Right! indentation trick me. Thanks for fixing it!
jeqo
left a comment
There was a problem hiding this comment.
LGTM, thanks @giuseppelillo!
As discussed internally, we can add metrics for sealed partitions in a follow-up 👍🏽
…ic to diskless (#533) Sealing is applied for both existing leaders and newly elected leaders.
Sealing is applied for both existing leaders and newly elected leaders.