MINOR: Standardize controller log4j output for replaying records#13703
MINOR: Standardize controller log4j output for replaying records#13703cmccabe merged 1 commit intoapache:trunkfrom
Conversation
93b0400 to
9a0af78
Compare
9a0af78 to
4d5177c
Compare
Standardize controller log4j output for replaying important records. The log message should include word "replayed" to make it clear that this is a record replay. Log the replay of records for ACLs, client quotas, and producer IDs, which were previously not logged. Also fix a case where we weren't logging changes to broker registrations. AclControlManager, ClientQuotaControlManager, and ProducerIdControlManager didn't previously have a log4j logger object, so this PR adds one. It also converts them to using Builder objects. This makes junit tests more readable because we don't need to specify paramaters where the test can use the default (like LogContexts). Throw an exception in replay if we get another TopicRecord for a topic which already exists.
4d5177c to
0800013
Compare
| log.info("Replayed partition assignment change {} for topic {}", record, topicInfo.name); | ||
| } else if (log.isTraceEnabled()) { | ||
| log.trace("Replayed partition change {} for topic {}", record, topicInfo.name); | ||
| } else if (log.isDebugEnabled()) { |
There was a problem hiding this comment.
Do we really need this check? My understanding is that the parameterised messages (which we are using here) removes the requirement of this check. see: https://www.slf4j.org/faq.html#logging_performance
There was a problem hiding this comment.
good point. I'll remove it.
metadata/src/main/java/org/apache/kafka/controller/ReplicationControlManager.java
Show resolved
Hide resolved
metadata/src/main/java/org/apache/kafka/controller/AclControlManager.java
Show resolved
Hide resolved
rondagostino
left a comment
There was a problem hiding this comment.
LGTM in general, just a few minor comments and a couple of places where it would be good to get your take on the issue raised, Colin.
metadata/src/main/java/org/apache/kafka/controller/AclControlManager.java
Show resolved
Hide resolved
metadata/src/main/java/org/apache/kafka/controller/ReplicationControlManager.java
Show resolved
Hide resolved
| log.info("Replayed partition assignment change {} for topic {}", record, topicInfo.name); | ||
| } else if (log.isTraceEnabled()) { | ||
| log.trace("Replayed partition change {} for topic {}", record, topicInfo.name); | ||
| } else if (log.isDebugEnabled()) { |
metadata/src/test/java/org/apache/kafka/controller/MockAclControlManager.java
Show resolved
Hide resolved
Well, the JUnit tests don't set the log context. The builder is useful for avoiding clutter in these tests. In general most of the controller manager objects should have builders. It just avoids having a huge amount of boilerplate in the tests (like dummy LogContext, SnapshotRegistry, objects etc.) It also makes it bearable to add new constructor parameters without updating every since test call site. |
mumrah
left a comment
There was a problem hiding this comment.
Thanks @cmccabe, this is a nice improvement. It's really confusing to look at controller logs and see nodes saying "Creating topic..." when really its just replaying the record.
Can you paste a snippet of some INFO logs with these changes and include in the PR description?
LGTM
|
Guys -- we really need to check builds before merging. Every time this happens, we are blocking people who are doing the right thing and checking their builds :( |
|
+1 @jolshan - is there a reason why people are not checking the build result? Particularly when it doesn't even compile. |
|
As I recall, we did check the Jenkins result, it's just that it was an old and stale build result. I should have re-run the build. Sorry. |
…che#13703) Standardize controller log4j output for replaying important records. The log message should include word "replayed" to make it clear that this is a record replay. Log the replay of records for ACLs, client quotas, and producer IDs, which were previously not logged. Also fix a case where we weren't logging changes to broker registrations. AclControlManager, ClientQuotaControlManager, and ProducerIdControlManager didn't previously have a log4j logger object, so this PR adds one. It also converts them to using Builder objects. This makes junit tests more readable because we don't need to specify paramaters where the test can use the default (like LogContexts). Throw an exception in replay if we get another TopicRecord for a topic which already exists. Example log messages: INFO [QuorumController id=3000] Replayed a FeatureLevelRecord setting metadata version to 3.6-IV0 DEBUG [QuorumController id=3000] Replayed a ZkMigrationStateRecord which did not alter the state from NONE. INFO [QuorumController id=3000] Replayed BrokerRegistrationChangeRecord modifying the registration for broker 0: BrokerRegistrationChangeRecord(brokerId=0, brokerEpoch=3, fenced=-1, inControlledShutdown=0) INFO [QuorumController id=3000] Replayed ClientQuotaRecord for ClientQuotaEntity(entries={user=testkit}) setting request_percentage to 0.99. Reviewers: Divij Vaidya <diviv@amazon.com>, Ron Dagostino <rndgstn@gmail.com>, David Arthur <mumrah@gmail.com>
Standardize controller log4j output for replaying important records. The log message should include word "replayed" to make it clear that this is a record replay. Log the replay of records for ACLs, client quotas, and producer IDs, which were previously not logged. Also fix a case where we weren't logging changes to broker registrations.
AclControlManager, ClientQuotaControlManager, and ProducerIdControlManager didn't previously have a log4j logger object, so this PR adds one. It also converts them to using Builder objects. This makes junit tests more readable because we don't need to specify paramaters where the test can use the default (like LogContexts).
Throw an exception in replay if we get another TopicRecord for a topic which already exists.
Example log messages:
INFO [QuorumController id=3000] Replayed a FeatureLevelRecord setting metadata version to 3.6-IV0
DEBUG [QuorumController id=3000] Replayed a ZkMigrationStateRecord which did not alter the state from NONE.
INFO [QuorumController id=3000] Replayed BrokerRegistrationChangeRecord modifying the registration for broker 0: BrokerRegistrationChangeRecord(brokerId=0, brokerEpoch=3, fenced=-1, inControlledShutdown=0)
INFO [QuorumController id=3000] Replayed ClientQuotaRecord for ClientQuotaEntity(entries={user=testkit}) setting request_percentage to 0.99.