Skip to content

Commit

Permalink
fix(core): implement parallelism in the creating log process (#963)
Browse files Browse the repository at this point in the history
Signed-off-by: SSpirits <[email protected]>
  • Loading branch information
ShadowySpirits authored Mar 18, 2024
1 parent 2d30a2f commit 8f8ddd9
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions core/src/main/scala/kafka/log/LogManager.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1057,7 +1057,9 @@ class LogManager(logDirs: Seq[File],
*/
def getOrCreateLog(topicPartition: TopicPartition, isNew: Boolean = false, isFuture: Boolean = false,
topicId: Option[Uuid], targetLogDirectoryId: Option[Uuid] = Option.empty, leaderEpoch: Long = 0): UnifiedLog = {
logCreationOrDeletionLock synchronized {
// Only Partition#makeLeader will create a new log, the ReplicaManager#asyncApplyDelta will ensure the same partition
// sequentially operate. So it's safe without lock
// logCreationOrDeletionLock synchronized {
val log = getLog(topicPartition, isFuture).getOrElse {
// create the log if it has not already been created in another thread
val now = time.milliseconds()
Expand Down Expand Up @@ -1148,7 +1150,7 @@ class LogManager(logDirs: Seq[File],
}
}
log
}
// }
}

private[log] def createLogDirectory(logDir: File, logDirName: String): Try[File] = {
Expand Down

0 comments on commit 8f8ddd9

Please sign in to comment.