-
Notifications
You must be signed in to change notification settings - Fork 15.4k
KAFKA-12426: Missing logic to create partition.metadata files in RaftReplicaManager #10282
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
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
9effa4f
Added partitionMetadata file code to RaftReplicaManager
jolshan 63439be
Check for inconsistent topic ID
jolshan de493a9
Merge branch 'trunk' of github.com:apache/kafka into KAFKA-12426
jolshan be36e6c
clean up merge change
jolshan 5e3372a
Cleaned style as recommended by review
jolshan 51b8f7e
Fixed bug that prevented writing to partition.metadata file on first …
jolshan 4e1a7c7
Merge branch 'trunk' of github.com:apache/kafka into KAFKA-12426
jolshan 2893d15
Removed optional argument and placement for partition.metadata file w…
jolshan ad65a25
Removed optional arguments, minor style changes
jolshan 2e5c8f6
Merge branch 'trunk' of github.com:apache/kafka into KAFKA-12426
jolshan fac1f7a
Small tweaks to style, made optional keepPartitionMetadata file non-o…
jolshan c221911
Address comments. Changed error message and cleaned up some code.
jolshan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,7 +22,7 @@ import kafka.log.Log | |
| import kafka.server.checkpoints.OffsetCheckpoints | ||
| import kafka.server.metadata.{MetadataBrokers, MetadataPartition} | ||
| import kafka.utils.Implicits.MapExtensionMethods | ||
| import org.apache.kafka.common.TopicPartition | ||
| import org.apache.kafka.common.{TopicPartition, Uuid} | ||
| import org.apache.kafka.common.errors.KafkaStorageException | ||
|
|
||
| import scala.collection.{Map, Set, mutable} | ||
|
|
@@ -72,7 +72,8 @@ class RaftReplicaChangeDelegate(helper: RaftReplicaChangeDelegateHelper) { | |
| def makeLeaders(prevPartitionsAlreadyExisting: Set[MetadataPartition], | ||
| partitionStates: Map[Partition, MetadataPartition], | ||
| highWatermarkCheckpoints: OffsetCheckpoints, | ||
| metadataOffset: Option[Long]): Set[Partition] = { | ||
| metadataOffset: Option[Long], | ||
| topicIds: String => Option[Uuid]): Set[Partition] = { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess we could use a strong type here since topicIds are required for KIP-500, but maybe not worth it since we are delegating to |
||
| val partitionsMadeLeaders = mutable.Set[Partition]() | ||
| val traceLoggingEnabled = helper.stateChangeLogger.isTraceEnabled | ||
| val deferredBatches = metadataOffset.isEmpty | ||
|
|
@@ -94,7 +95,7 @@ class RaftReplicaChangeDelegate(helper: RaftReplicaChangeDelegateHelper) { | |
| try { | ||
| val isrState = state.toLeaderAndIsrPartitionState( | ||
| !prevPartitionsAlreadyExisting(state)) | ||
| if (partition.makeLeader(isrState, highWatermarkCheckpoints)) { | ||
| if (partition.makeLeader(isrState, highWatermarkCheckpoints, topicIds(partition.topic))) { | ||
| partitionsMadeLeaders += partition | ||
| if (traceLoggingEnabled) { | ||
| helper.stateChangeLogger.trace(s"$partitionLogMsgPrefix: completed the become-leader state change.") | ||
|
|
@@ -125,7 +126,8 @@ class RaftReplicaChangeDelegate(helper: RaftReplicaChangeDelegateHelper) { | |
| currentBrokers: MetadataBrokers, | ||
| partitionStates: Map[Partition, MetadataPartition], | ||
| highWatermarkCheckpoints: OffsetCheckpoints, | ||
| metadataOffset: Option[Long]): Set[Partition] = { | ||
| metadataOffset: Option[Long], | ||
| topicIds: String => Option[Uuid]): Set[Partition] = { | ||
| val traceLoggingEnabled = helper.stateChangeLogger.isTraceEnabled | ||
| val deferredBatches = metadataOffset.isEmpty | ||
| val topLevelLogPrefix = if (deferredBatches) | ||
|
|
@@ -164,10 +166,10 @@ class RaftReplicaChangeDelegate(helper: RaftReplicaChangeDelegateHelper) { | |
| s"since the new leader ${state.leaderId} is unavailable.") | ||
| // Create the local replica even if the leader is unavailable. This is required to ensure that we include | ||
| // the partition's high watermark in the checkpoint file (see KAFKA-1647) | ||
| partition.createLogIfNotExists(isNew, isFutureReplica = false, highWatermarkCheckpoints) | ||
| partition.createLogIfNotExists(isNew, isFutureReplica = false, highWatermarkCheckpoints, topicIds(partition.topic)) | ||
| } else { | ||
| val isrState = state.toLeaderAndIsrPartitionState(isNew) | ||
| if (partition.makeFollower(isrState, highWatermarkCheckpoints)) { | ||
| if (partition.makeFollower(isrState, highWatermarkCheckpoints, topicIds(partition.topic))) { | ||
| partitionsMadeFollower += partition | ||
| if (traceLoggingEnabled) { | ||
| helper.stateChangeLogger.trace(s"$partitionLogMsgPrefix: completed the " + | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.