Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2990,9 +2990,14 @@ List<ApiMessageAndVersion> markClassicToDisklessSwitchStarted(
for (Entry<Integer, PartitionRegistration> partEntry : topicInfo.parts.entrySet()) {
PartitionRegistration partition = partEntry.getValue();
if (partition.classicToDisklessStartOffset == PartitionRegistration.NO_CLASSIC_TO_DISKLESS_START_OFFSET) {
if (partition.leader == NO_LEADER) {
log.warn("Partition {}-{} has no leader; classic-to-diskless switch will " +
"remain pending until a leader is elected", topicName, partEntry.getKey());
}
PartitionChangeRecord record = new PartitionChangeRecord()
.setTopicId(topicId)
.setPartitionId(partEntry.getKey());
.setPartitionId(partEntry.getKey())
.setLeader(partition.leader); // Force leader epoch bump to trigger makeLeader on broker
record.unknownTaggedFields().add(
InitDisklessLogFields.encodeClassicToDisklessStartOffset(
PartitionRegistration.CLASSIC_TO_DISKLESS_SWITCH_PENDING));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6524,13 +6524,24 @@ public void testMarkClassicToDisklessSwitchStartedSuccess() {
assertEquals(topicId, record.topicId());
assertEquals(PartitionRegistration.CLASSIC_TO_DISKLESS_SWITCH_PENDING,
InitDisklessLogFields.decodeClassicToDisklessStartOffset(record.unknownTaggedFields()));
// Leader must be set to force epoch bump on broker
int partitionId = record.partitionId();
int expectedLeader = replicationControl.getPartition(topicId, partitionId).leader;
assertEquals(expectedLeader, record.leader());
}

int[] epochsBefore = new int[2];
for (int i = 0; i < 2; i++) {
epochsBefore[i] = replicationControl.getPartition(topicId, i).leaderEpoch;
}

ctx.replay(records);
for (int i = 0; i < 2; i++) {
PartitionRegistration partition = replicationControl.getPartition(topicId, i);
assertEquals(PartitionRegistration.CLASSIC_TO_DISKLESS_SWITCH_PENDING,
partition.classicToDisklessStartOffset);
// Leader epoch must be bumped to trigger makeLeader on broker
assertEquals(epochsBefore[i] + 1, partition.leaderEpoch);
}
}

Expand Down
Loading