Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
9fd69d7
Add HostedPartition.Fenced to ReplicaManager
rondagostino Jan 22, 2021
fef34f6
implement makeFenced()
rondagostino Jan 23, 2021
fdc1f5b
cleanups
rondagostino Jan 23, 2021
d9fa4dd
Implement unfencing of leader partitions
rondagostino Jan 25, 2021
0324d5b
Merge remote-tracking branch 'origin/kip-500' into rtd_HostedPartitio…
rondagostino Jan 25, 2021
f4bf859
Implemented unfenceFencedFollowerPartitions()
rondagostino Jan 25, 2021
2a78717
Merge remote-tracking branch 'origin/kip-500' into rtd_HostedPartitio…
rondagostino Jan 25, 2021
d667f38
Merge remote-tracking branch 'origin/kip-500' into rtd_HostedPartitio…
rondagostino Jan 26, 2021
776eae4
Eliminate fencedPartitionStates
rondagostino Jan 26, 2021
8620ea4
Eliminate "get" prefix on long method names
rondagostino Jan 26, 2021
fe98cd6
Rename "Fenced" to "Deferred"
rondagostino Jan 26, 2021
d2d688b
renames for clarity/risk mitigation, respond to some review comments
rondagostino Jan 27, 2021
1f019dc
Defer changes when using Raft only/fix failng tests
rondagostino Jan 27, 2021
c4487d5
Merge remote-tracking branch 'origin/kip-500' into rtd_HostedPartitio…
rondagostino Jan 27, 2021
a4d238b
invoke onLeadershipChange() when applying deferred changes
rondagostino Jan 27, 2021
09c5966
Merge remote-tracking branch 'origin/kip-500' into rtd_HostedPartitio…
rondagostino Jan 27, 2021
eebc368
Reuse makeLeader/makeFollower helpers
rondagostino Jan 27, 2021
993ca24
Do not expose deferred partitions
rondagostino Jan 27, 2021
275ef23
Merge remote-tracking branch 'origin/kip-500' into rtd_HostedPartitio…
rondagostino Jan 28, 2021
32bcfec
Merge remote-tracking branch 'origin/kip-500' into rtd_HostedPartitio…
rondagostino Jan 28, 2021
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 @@ -833,7 +833,7 @@ class GroupMetadataManager(brokerId: Int,
val timestampType = TimestampType.CREATE_TIME
val timestamp = time.milliseconds()

replicaManager.nonOfflinePartition(appendPartition).foreach { partition =>
replicaManager.onlinePartition(appendPartition).foreach { partition =>
val tombstones = ArrayBuffer.empty[SimpleRecord]
removedOffsets.forKeyValue { (topicPartition, offsetAndMetadata) =>
trace(s"Removing expired/deleted offset and metadata for $groupId, $topicPartition: $offsetAndMetadata")
Expand Down
4 changes: 3 additions & 1 deletion core/src/main/scala/kafka/log/LogManager.scala
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,9 @@ class LogManager(logDirs: Seq[File],
val numLogsLoaded = new AtomicInteger(0)
numTotalLogs += logsToLoad.length

val jobsForDir = logsToLoad.map { logDir =>
val jobsForDir = logsToLoad
.filter(logDir => Log.parseTopicPartitionName(logDir).topic != "@metadata")
.map { logDir =>
val runnable: Runnable = () => {
try {
debug(s"Loading log $logDir")
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/scala/kafka/server/BrokerServer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ class BrokerServer(
this.replicaManager = new ReplicaManager(config, metrics, time, None,
kafkaScheduler, logManager, isShuttingDown, quotaManagers,
brokerTopicStats, metadataCache, logDirFailureChannel, alterIsrManager,
configRepository, threadNamePrefix)
configRepository, threadNamePrefix, true)

/* start broker-to-controller channel managers */
val controllerNodes =
Expand Down
2 changes: 2 additions & 0 deletions core/src/main/scala/kafka/server/DelayedDeleteRecords.scala
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ class DelayedDeleteRecords(delayMs: Long,
case None =>
(false, Errors.NOT_LEADER_OR_FOLLOWER, DeleteRecordsResponse.INVALID_LOW_WATERMARK)
}
case HostedPartition.Deferred(_, _, _, _, _) =>
(false, Errors.NOT_LEADER_OR_FOLLOWER, DeleteRecordsResponse.INVALID_LOW_WATERMARK)

case HostedPartition.Offline =>
(false, Errors.KAFKA_STORAGE_ERROR, DeleteRecordsResponse.INVALID_LOW_WATERMARK)
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/scala/kafka/server/DelayedFetch.scala
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ class DelayedFetch(delayMs: Long,
val fetchLeaderEpoch = fetchStatus.fetchInfo.currentLeaderEpoch
try {
if (fetchOffset != LogOffsetMetadata.UnknownOffsetMetadata) {
val partition = replicaManager.getPartitionOrException(topicPartition)
val partition = replicaManager.onlinePartitionOrException(topicPartition)
val offsetSnapshot = partition.fetchOffsetSnapshot(fetchLeaderEpoch, fetchMetadata.fetchOnlyLeader)

val endOffset = fetchMetadata.fetchIsolation match {
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/scala/kafka/server/DelayedProduce.scala
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class DelayedProduce(delayMs: Long,
trace(s"Checking produce satisfaction for $topicPartition, current status $status")
// skip those partitions that have already been satisfied
if (status.acksPending) {
val (hasEnough, error) = replicaManager.getPartitionOrError(topicPartition) match {
val (hasEnough, error) = replicaManager.onlinePartitionOrError(topicPartition) match {
case Left(err) =>
// Case A
(false, err)
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/scala/kafka/server/KafkaServer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ class KafkaServer(
time, config.brokerId, () => kafkaController.brokerEpoch)
new ReplicaManager(config, metrics, time, Some(zkClient), kafkaScheduler, logManager,
isShuttingDown, quotaManagers, brokerTopicStats, metadataCache, logDirFailureChannel,
alterIsrManager, new ZkConfigRepository(new AdminZkClient(zkClient)), None)
alterIsrManager, new ZkConfigRepository(new AdminZkClient(zkClient)), None, false)
}

private def initZkClient(time: Time): Unit = {
Expand Down
Empty file.
24 changes: 12 additions & 12 deletions core/src/main/scala/kafka/server/ReplicaAlterLogDirsThread.scala
Original file line number Diff line number Diff line change
Expand Up @@ -60,19 +60,19 @@ class ReplicaAlterLogDirsThread(name: String,
private var inProgressPartition: Option[TopicPartition] = None

override protected def latestEpoch(topicPartition: TopicPartition): Option[Int] = {
replicaMgr.futureLocalLogOrException(topicPartition).latestEpoch
replicaMgr.futureLocalOnlineLogOrException(topicPartition).latestEpoch
}

override protected def logStartOffset(topicPartition: TopicPartition): Long = {
replicaMgr.futureLocalLogOrException(topicPartition).logStartOffset
replicaMgr.futureLocalOnlineLogOrException(topicPartition).logStartOffset
}

override protected def logEndOffset(topicPartition: TopicPartition): Long = {
replicaMgr.futureLocalLogOrException(topicPartition).logEndOffset
replicaMgr.futureLocalOnlineLogOrException(topicPartition).logEndOffset
}

override protected def endOffsetForEpoch(topicPartition: TopicPartition, epoch: Int): Option[OffsetAndEpoch] = {
replicaMgr.futureLocalLogOrException(topicPartition).endOffsetForEpoch(epoch)
replicaMgr.futureLocalOnlineLogOrException(topicPartition).endOffsetForEpoch(epoch)
}

def fetchFromLeader(fetchRequest: FetchRequest.Builder): Map[TopicPartition, FetchData] = {
Expand Down Expand Up @@ -110,7 +110,7 @@ class ReplicaAlterLogDirsThread(name: String,
override def processPartitionData(topicPartition: TopicPartition,
fetchOffset: Long,
partitionData: PartitionData[Records]): Option[LogAppendInfo] = {
val partition = replicaMgr.nonOfflinePartition(topicPartition).get
val partition = replicaMgr.onlinePartition(topicPartition).get
val futureLog = partition.futureLocalLogOrException
val records = toMemoryRecords(partitionData.records)

Expand Down Expand Up @@ -139,7 +139,7 @@ class ReplicaAlterLogDirsThread(name: String,
// 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.filter { case (tp, _) =>
replicaMgr.futureLogExists(tp)
replicaMgr.futureLocalOnlineLogExists(tp)
}
super.addPartitions(filteredFetchStates)
} finally {
Expand All @@ -148,12 +148,12 @@ class ReplicaAlterLogDirsThread(name: String,
}

override protected def fetchEarliestOffsetFromLeader(topicPartition: TopicPartition, leaderEpoch: Int): Long = {
val partition = replicaMgr.getPartitionOrException(topicPartition)
val partition = replicaMgr.onlinePartitionOrException(topicPartition)
partition.localLogOrException.logStartOffset
}

override protected def fetchLatestOffsetFromLeader(topicPartition: TopicPartition, leaderEpoch: Int): Long = {
val partition = replicaMgr.getPartitionOrException(topicPartition)
val partition = replicaMgr.onlinePartitionOrException(topicPartition)
partition.localLogOrException.logEndOffset
}

Expand All @@ -170,7 +170,7 @@ class ReplicaAlterLogDirsThread(name: String,
.setPartition(tp.partition)
.setErrorCode(Errors.NONE.code)
} else {
val partition = replicaMgr.getPartitionOrException(tp)
val partition = replicaMgr.onlinePartitionOrException(tp)
partition.lastOffsetForLeaderEpoch(
currentLeaderEpoch = epochData.currentLeaderEpoch,
leaderEpoch = epochData.leaderEpoch,
Expand Down Expand Up @@ -206,12 +206,12 @@ class ReplicaAlterLogDirsThread(name: String,
* exchange with the current replica to truncate to the largest common log prefix for the topic partition
*/
override def truncate(topicPartition: TopicPartition, truncationState: OffsetTruncationState): Unit = {
val partition = replicaMgr.getPartitionOrException(topicPartition)
val partition = replicaMgr.onlinePartitionOrException(topicPartition)
partition.truncateTo(truncationState.offset, isFuture = true)
}

override protected def truncateFullyAndStartAt(topicPartition: TopicPartition, offset: Long): Unit = {
val partition = replicaMgr.getPartitionOrException(topicPartition)
val partition = replicaMgr.onlinePartitionOrException(topicPartition)
partition.truncateFullyAndStartAt(offset, isFuture = true)
}

Expand Down Expand Up @@ -255,7 +255,7 @@ class ReplicaAlterLogDirsThread(name: String,
val partitionsWithError = mutable.Set[TopicPartition]()

try {
val logStartOffset = replicaMgr.futureLocalLogOrException(tp).logStartOffset
val logStartOffset = replicaMgr.futureLocalOnlineLogOrException(tp).logStartOffset
val lastFetchedEpoch = if (isTruncationOnFetchSupported)
fetchState.lastFetchedEpoch.map(_.asInstanceOf[Integer]).asJava
else
Expand Down
14 changes: 7 additions & 7 deletions core/src/main/scala/kafka/server/ReplicaFetcherThread.scala
Original file line number Diff line number Diff line change
Expand Up @@ -109,19 +109,19 @@ class ReplicaFetcherThread(name: String,
val fetchSessionHandler = new FetchSessionHandler(logContext, sourceBroker.id)

override protected def latestEpoch(topicPartition: TopicPartition): Option[Int] = {
replicaMgr.localLogOrException(topicPartition).latestEpoch
replicaMgr.localOnlineLogOrException(topicPartition).latestEpoch
}

override protected def logStartOffset(topicPartition: TopicPartition): Long = {
replicaMgr.localLogOrException(topicPartition).logStartOffset
replicaMgr.localOnlineLogOrException(topicPartition).logStartOffset
}

override protected def logEndOffset(topicPartition: TopicPartition): Long = {
replicaMgr.localLogOrException(topicPartition).logEndOffset
replicaMgr.localOnlineLogOrException(topicPartition).logEndOffset
}

override protected def endOffsetForEpoch(topicPartition: TopicPartition, epoch: Int): Option[OffsetAndEpoch] = {
replicaMgr.localLogOrException(topicPartition).endOffsetForEpoch(epoch)
replicaMgr.localOnlineLogOrException(topicPartition).endOffsetForEpoch(epoch)
}

override def initiateShutdown(): Boolean = {
Expand Down Expand Up @@ -158,7 +158,7 @@ class ReplicaFetcherThread(name: String,
fetchOffset: Long,
partitionData: FetchData): Option[LogAppendInfo] = {
val logTrace = isTraceEnabled
val partition = replicaMgr.nonOfflinePartition(topicPartition).get
val partition = replicaMgr.onlinePartition(topicPartition).get
val log = partition.localLogOrException
val records = toMemoryRecords(partitionData.records)

Expand Down Expand Up @@ -308,7 +308,7 @@ class ReplicaFetcherThread(name: String,
* The logic for finding the truncation offset is implemented in AbstractFetcherThread.getOffsetTruncationState
*/
override def truncate(tp: TopicPartition, offsetTruncationState: OffsetTruncationState): Unit = {
val partition = replicaMgr.nonOfflinePartition(tp).get
val partition = replicaMgr.onlinePartition(tp).get
val log = partition.localLogOrException

partition.truncateTo(offsetTruncationState.offset, isFuture = false)
Expand All @@ -324,7 +324,7 @@ class ReplicaFetcherThread(name: String,
}

override protected def truncateFullyAndStartAt(topicPartition: TopicPartition, offset: Long): Unit = {
val partition = replicaMgr.nonOfflinePartition(topicPartition).get
val partition = replicaMgr.onlinePartition(topicPartition).get
partition.truncateFullyAndStartAt(offset, isFuture = false)
}

Expand Down
Loading