Skip to content

MINOR: Standardize controller log4j output for replaying records#13703

Merged
cmccabe merged 1 commit intoapache:trunkfrom
cmccabe:cmccabe_2023-05-10_cleanup
Jul 13, 2023
Merged

MINOR: Standardize controller log4j output for replaying records#13703
cmccabe merged 1 commit intoapache:trunkfrom
cmccabe:cmccabe_2023-05-10_cleanup

Conversation

@cmccabe
Copy link
Contributor

@cmccabe cmccabe commented May 10, 2023

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.

@cmccabe cmccabe added the kraft label May 10, 2023
@cmccabe cmccabe force-pushed the cmccabe_2023-05-10_cleanup branch from 93b0400 to 9a0af78 Compare May 10, 2023 18:03
@rondagostino rondagostino self-assigned this May 11, 2023
@cmccabe cmccabe force-pushed the cmccabe_2023-05-10_cleanup branch from 9a0af78 to 4d5177c Compare May 11, 2023 19:02
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.
@cmccabe cmccabe force-pushed the cmccabe_2023-05-10_cleanup branch from 4d5177c to 0800013 Compare May 16, 2023 19:45
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()) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point. I'll remove it.

Copy link
Contributor

@rondagostino rondagostino left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

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()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

@cmccabe
Copy link
Contributor Author

cmccabe commented Jul 13, 2023

And all of these builder log contexts do get explicitly set in QuorumController (including the new ones via this PR), so the default will never be used. So my guess is the answer is no, it isn't worth doing. Colin, WDYT?

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.

Copy link
Member

@mumrah mumrah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@cmccabe cmccabe merged commit 959f9ca into apache:trunk Jul 13, 2023
@cmccabe cmccabe deleted the cmccabe_2023-05-10_cleanup branch July 13, 2023 20:27
@jolshan
Copy link
Member

jolshan commented Jul 14, 2023

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 :(

@ijuma
Copy link
Member

ijuma commented Jul 15, 2023

+1 @jolshan - is there a reason why people are not checking the build result? Particularly when it doesn't even compile.

@cmccabe
Copy link
Contributor Author

cmccabe commented Jul 16, 2023

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.

Cerchie pushed a commit to Cerchie/kafka that referenced this pull request Jul 25, 2023
…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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants