-
Notifications
You must be signed in to change notification settings - Fork 15.4k
KAFKA-9750; Fix race condition with log dir reassign completion #8412
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
Changes from 1 commit
553ab81
2580441
d9df438
9dd4ec7
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 |
|---|---|---|
|
|
@@ -91,7 +91,7 @@ class ReplicaAlterLogDirsThread(name: String, | |
| Request.FutureLocalReplicaId, | ||
| request.minBytes, | ||
| request.maxBytes, | ||
| request.version <= 2, | ||
| false, | ||
| request.fetchData.asScala.toSeq, | ||
| UnboundedQuota, | ||
| processResponseCallback, | ||
|
|
@@ -116,7 +116,11 @@ class ReplicaAlterLogDirsThread(name: String, | |
| throw new IllegalStateException("Offset mismatch for the future replica %s: fetched offset = %d, log end offset = %d.".format( | ||
| topicPartition, fetchOffset, futureLog.logEndOffset)) | ||
|
|
||
| val logAppendInfo = partition.appendRecordsToFollowerOrFutureReplica(records, isFuture = true) | ||
| val logAppendInfo = if (records.sizeInBytes() > 0) | ||
| partition.appendRecordsToFollowerOrFutureReplica(records, isFuture = true) | ||
| else | ||
| None | ||
|
|
||
| futureLog.updateHighWatermark(partitionData.highWatermark) | ||
| futureLog.maybeIncrementLogStartOffset(partitionData.logStartOffset) | ||
|
|
||
|
|
@@ -127,6 +131,19 @@ class ReplicaAlterLogDirsThread(name: String, | |
| logAppendInfo | ||
| } | ||
|
|
||
| override def addPartitions(initialFetchStates: Map[TopicPartition, OffsetAndEpoch]): Set[TopicPartition] = { | ||
| partitionMapLock.lockInterruptibly() | ||
| try { | ||
| // It is possible that the log dir fetcher completed just before this call, so we | ||
| // filter only the partitions which still have a future log dir. | ||
| val filteredFetchStates = initialFetchStates.filterKeys(replicaMgr.futureLogExists) | ||
|
Member
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. So there is a extra check of future folder here and the check is in the lock so the race condition is resolved. |
||
| super.addPartitions(filteredFetchStates) | ||
|
Member
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. Should we skip to create thread if the collection of filtered states is empty?
Member
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 think this will be a no-op in |
||
| filteredFetchStates.keySet | ||
|
Member
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. seems this line is useless. |
||
| } finally { | ||
| partitionMapLock.unlock() | ||
| } | ||
| } | ||
|
|
||
| override protected def fetchEarliestOffsetFromLeader(topicPartition: TopicPartition, leaderEpoch: Int): Long = { | ||
| val partition = replicaMgr.getPartitionOrException(topicPartition, expectLeader = false) | ||
| partition.localLogOrException.logStartOffset | ||
|
|
||
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 always build with the latest fetch version, so this check was unneeded.