-
Notifications
You must be signed in to change notification settings - Fork 14.7k
KAFKA-19648: Formatter refactoring #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 2 commits
a9c79a3
2a6f663
752a79e
026da2b
7e303b9
584fe3d
462e072
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,8 +509,9 @@ 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.