-
Notifications
You must be signed in to change notification settings - Fork 14.2k
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
KAFKA-17668: Clean-up LogCleaner#maxOverCleanerThreads and LogCleanerManager#maintainUncleanablePartitions #17390
Changes from 11 commits
a85b26f
1839a06
6dbd244
ec74070
b835c1f
a9468ec
ffe6689
38ecab8
e2ad6f6
4530b27
f0370c0
62483f1
80cbd3d
83d61d2
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 |
---|---|---|
|
@@ -2045,6 +2045,34 @@ class LogCleanerTest extends Logging { | |
} | ||
} | ||
|
||
@Test | ||
def testMaxOverCleanerThreads(): Unit = { | ||
val logCleaner = new LogCleaner(new CleanerConfig(true), | ||
logDirs = Array(TestUtils.tempDir(), TestUtils.tempDir()), | ||
logs = new Pool[TopicPartition, UnifiedLog](), | ||
logDirFailureChannel = new LogDirFailureChannel(1), | ||
time = time) | ||
|
||
val cleaners = mutable.ArrayBuffer[logCleaner.CleanerThread]() | ||
|
||
val cleaner1 = new logCleaner.CleanerThread(1) | ||
cleaner1.lastStats = new CleanerStats(time) | ||
cleaner1.lastStats.bufferUtilization = 0.75d | ||
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. Nit: 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. Thank you 😸 |
||
cleaners += cleaner1 | ||
|
||
val cleaner2 = new logCleaner.CleanerThread(2) | ||
cleaner2.lastStats = new CleanerStats(time) | ||
cleaner2.lastStats.bufferUtilization = 0.85d | ||
cleaners += cleaner2 | ||
|
||
val cleaner3 = new logCleaner.CleanerThread(3) | ||
cleaner3.lastStats = new CleanerStats(time) | ||
cleaner3.lastStats.bufferUtilization = 0.65d | ||
cleaners += cleaner3 | ||
|
||
assertEquals(0, logCleaner.maxOverCleanerThreads(_.lastStats.bufferUtilization)) | ||
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. Hmm, can we also assert a non zero value? 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. Sure! 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. In reviewing this test, I noticed that I introduced a bug in #8783 that I round down the double value when updating metrics I open https://issues.apache.org/jira/browse/KAFKA-18597 to fix it 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. Good catch. I'll backport this one to 4.0 to make it easier to backport the bug fix. 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. Also, given the fix, perhaps we don't need the case where we set the bufferUtilization to larger numbers. 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.
you are right. I copy your comment to #18627 |
||
} | ||
|
||
private def writeToLog(log: UnifiedLog, keysAndValues: Iterable[(Int, Int)], offsetSeq: Iterable[Long]): Iterable[Long] = { | ||
for (((key, value), offset) <- keysAndValues.zip(offsetSeq)) | ||
yield log.appendAsFollower(messageWithOffset(key, value, offset)).lastOffset | ||
|
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.
ditto.
LogCleanerManagerTest
is a good place :)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.
maintainUncleanablePartitions
is invoked byCleanerThread#doWork
, which is a daemon thread. It has been ㄎwidely tested through integration tests and unit tests related to LogCleaner. IMHO, we can leverage these existing tests and don't need to write new ones.