KAFKA-19386: Correcting ExpirationReaper thread names from Purgatory#19918
Conversation
| this.purgeInterval = purgeInterval; | ||
| this.reaperEnabled = reaperEnabled; | ||
| this.timerEnabled = timerEnabled; | ||
| this.expirationReaper = new ExpiredOperationReaper(); |
There was a problem hiding this comment.
that seems error-prone to me, since the issue is caused by an incorrect initialization order. Perhaps we should use anonymous class to ensure the initialization order. for example:
this.expirationReaper = new ShutdownableThread("ExpirationReaper-" + brokerId + "-" + purgatoryName, false) {
@Override
public void doWork() {
try {
advanceClock(200L);
} catch (InterruptedException ie) {
throw new RuntimeException(ie);
}
}
};There was a problem hiding this comment.
Hmmm, is it really required as expirationReaper.start(); is post initialization of other objects?
There was a problem hiding this comment.
Apologies for unclear comment. My point was that the expirationReaper initialization must happen after brokerId and purgatoryName are initialized. The dependency is implicit, which means we might inadvertently re-introduce a bug during future refactoring. Using an anonymous class could eliminate the happen-before constraint as it can directly reference the input arguments.
Alternatively, we could add comments to explicitly remind developers that expirationReaper must be initialized after brokerId and purgatoryName
There was a problem hiding this comment.
Make sense. I have added the comment for now. Though the other suggestion was also valid.
The PR: #17636 migrated
DelayedOperationPurgatory from scala to java, and instatiated
expirationReaperat instance level wherepurgatoryNameis stillnullhence all expiration threads from different Purgatories hasincorrect names.
The PR fixes the instatiation of ExpirationReaper, in constructor when
purgatoryNameis defined.This issue affects 4.0 version as well, though minor.
Reviewers: Chia-Ping Tsai chia7712@gmail.com