-
Notifications
You must be signed in to change notification settings - Fork 14.8k
KAFKA-19648: KIP-1170 Unify cluster metadata bootstrapping #20707
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: trunk
Are you sure you want to change the base?
Changes from 4 commits
a9c79a3
2a6f663
752a79e
026da2b
7e303b9
584fe3d
9852262
9cb5318
ff3c050
f5763d0
f3a3e41
0ab8e02
1f76fa9
4de55ce
56435b3
29affeb
533033b
f35e992
1c4528e
625acfb
cb2ad18
3c809c1
1908b2c
7226af0
029aa6b
6dbef44
cc3f0b4
7ad1342
135c126
383045a
b474770
721fb5c
cb4803d
6a46cf7
adb1548
a839631
96bc7f3
4823d30
082d469
dae3bd9
8ebfdaf
5ba0c9b
a7450e0
dcd1b0b
67ad6c4
0a78d0d
de4da73
eb4ba90
1d1e7ba
dc27d7c
8469809
2e0c8f0
a182b12
0da0919
fd3adf6
3d589e6
56dae1b
b3feaa6
03eafae
7e8d2e6
7a9404f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -437,14 +437,11 @@ void doFormat(BootstrapMetadata bootstrapMetadata) throws Exception { | |||||||||||
| directoryTypes.get(writeLogDir).description(), writeLogDir, | ||||||||||||
| MetadataVersion.FEATURE_NAME, releaseVersion); | ||||||||||||
| Files.createDirectories(Paths.get(writeLogDir)); | ||||||||||||
| BootstrapDirectory bootstrapDirectory = new BootstrapDirectory(writeLogDir); | ||||||||||||
| bootstrapDirectory.writeBinaryFile(bootstrapMetadata); | ||||||||||||
| if (directoryTypes.get(writeLogDir).isDynamicMetadataDirectory()) { | ||||||||||||
| writeDynamicQuorumSnapshot(writeLogDir, | ||||||||||||
| initialControllers.get(), | ||||||||||||
| featureLevels.get(KRaftVersion.FEATURE_NAME), | ||||||||||||
| controllerListenerName); | ||||||||||||
| } | ||||||||||||
| writeBoostrapSnapshot(writeLogDir, | ||||||||||||
| bootstrapMetadata, | ||||||||||||
| initialControllers.get(), | ||||||||||||
|
||||||||||||
| featureLevels.get(KRaftVersion.FEATURE_NAME), | ||||||||||||
| controllerListenerName); | ||||||||||||
| }); | ||||||||||||
| copier.setWriteErrorHandler((errorLogDir, e) -> { | ||||||||||||
| throw new FormatterException("Error while writing meta.properties file " + | ||||||||||||
|
|
@@ -492,8 +489,9 @@ static DirectoryType calculate( | |||||||||||
| } | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| static void writeDynamicQuorumSnapshot( | ||||||||||||
| static void writeBoostrapSnapshot( | ||||||||||||
| String writeLogDir, | ||||||||||||
| BootstrapMetadata bootstrapMetadata, | ||||||||||||
| DynamicVoters initialControllers, | ||||||||||||
| short kraftVersion, | ||||||||||||
| String controllerListenerName | ||||||||||||
|
|
@@ -511,7 +509,7 @@ static void writeDynamicQuorumSnapshot( | |||||||||||
| Snapshots.BOOTSTRAP_SNAPSHOT_ID)). | ||||||||||||
| setKraftVersion(KRaftVersion.fromFeatureLevel(kraftVersion)). | ||||||||||||
| setVoterSet(Optional.of(voterSet)); | ||||||||||||
| try (RecordsSnapshotWriter<ApiMessageAndVersion> writer = builder.build(new MetadataRecordSerde())) { | ||||||||||||
| try (RecordsSnapshotWriter<ApiMessageAndVersion> writer = builder.build(new MetadataRecordSerde(), Optional.of(bootstrapMetadata.records()))) { | ||||||||||||
| writer.freeze(); | ||||||||||||
|
||||||||||||
| try (RecordsSnapshotWriter<ApiMessageAndVersion> writer = builder.build(new MetadataRecordSerde(), Optional.of(bootstrapMetadata.records()))) { | |
| writer.freeze(); | |
| try (RecordsSnapshotWriter<ApiMessageAndVersion> writer = builder.build(new MetadataRecordSerde()))) { | |
| writer.append(bootstrapMetadata.records()); | |
| writer.freeze(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't this write the bootstrap records after the control records, since in RecordsSnapshotWriter.build() is where we append the kraft records and we would be calling that ahead of writer.append in this scenario? we want the bootstrap records ahead correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't matter what order we write them in because KRaft only reads the control records, and the metadata module will only read the "data" records. When we read the 0-0.checkpoint back into memory, we only deal with either its control records or its data records, not both in the same code.
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a clearer way to make these changes. This method is what writes the 0-0.checkpoint currently. We should pass the bootstrap metadata object here and append the metadata records using writer.append.append(bootstrapMetadata.records()) before calling writer.freeze().
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should be able to remove this. This applies to other instances where we build the RecordsSnapshotWriter.