Skip to content
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-5111: code cleanup follow up #2917

Closed
wants to merge 5 commits into from

Conversation

mjsax
Copy link
Member

@mjsax mjsax commented Apr 26, 2017

  • mainly moving methods
  • also improved logging

@mjsax
Copy link
Member Author

mjsax commented Apr 26, 2017

Call for review @enothereska @dguy @guozhangwang

This is a follow-up for #2895 with the code cleanup commit that I did remove (moving around methods). I also put a second commit on top to improving logging. This PR also addresses as remaining nits from #2895

Copy link
Contributor

@dguy dguy left a comment

Choose a reason for hiding this comment

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

couple minor comments, otherwise LGTM

@@ -122,14 +105,14 @@ public void commit() {
*/
@Override
public void suspend() {
log.info("{} Suspending", logPrefix);
log.debug("{} Suspending", logPrefix);
Copy link
Contributor

Choose a reason for hiding this comment

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

any reason why we are changing these from info to debug?

Copy link
Member Author

Choose a reason for hiding this comment

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

We log suspended tasks at info level in StreamThread already.

Copy link
Contributor

Choose a reason for hiding this comment

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

Seems we are not actually?

for (final AbstractTask task : activeAndStandbytasks()) {
 +            try {
 +                task.suspend();
 +            } catch (final RuntimeException e) {
 +                firstException.compareAndSet(null, e);
 +            }
 +        }

Copy link
Member Author

Choose a reason for hiding this comment

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

We do. It's little further up:

        log.debug("{} suspendTasksAndState: suspending all active tasks {} and standby tasks {}",
            logPrefix, activeTasks.keySet(), standbyTasks.keySet());

        final AtomicReference<RuntimeException> firstException = new AtomicReference<>(null);

        for (final AbstractTask task : activeAndStandbytasks()) {
            try {
                task.suspend();
            } catch (final RuntimeException e) {
                firstException.compareAndSet(null, e);
            }
        }

Copy link
Contributor

Choose a reason for hiding this comment

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

@mjsax Just realized we already have an info log entry in onPartitionXX callbacks, so this should be fine. NVM.

final Sensor taskCommitTimeSensor;


public TaskMetrics(final StreamsMetrics metrics) {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: can be package private

@asfbot
Copy link

asfbot commented Apr 26, 2017

Refer to this link for build results (access rights to CI server needed):
https://builds.apache.org/job/kafka-pr-jdk8-scala2.11/3182/
Test PASSed (JDK 8 and Scala 2.11).

@mjsax mjsax changed the title Kafka 5111 code cleanup follow up KAFKA-5111: code cleanup follow up Apr 26, 2017
@mjsax
Copy link
Member Author

mjsax commented Apr 26, 2017

Updated this.

@asfbot
Copy link

asfbot commented Apr 26, 2017

Refer to this link for build results (access rights to CI server needed):
https://builds.apache.org/job/kafka-pr-jdk7-scala2.10/3182/
Test PASSed (JDK 7 and Scala 2.10).

@asfbot
Copy link

asfbot commented Apr 26, 2017

Refer to this link for build results (access rights to CI server needed):
https://builds.apache.org/job/kafka-pr-jdk8-scala2.12/3177/
Test PASSed (JDK 8 and Scala 2.12).

@asfbot
Copy link

asfbot commented Apr 27, 2017

Refer to this link for build results (access rights to CI server needed):
https://builds.apache.org/job/kafka-pr-jdk8-scala2.12/3197/
Test PASSed (JDK 8 and Scala 2.12).

@asfbot
Copy link

asfbot commented Apr 27, 2017

Refer to this link for build results (access rights to CI server needed):
https://builds.apache.org/job/kafka-pr-jdk7-scala2.10/3199/
Test PASSed (JDK 7 and Scala 2.10).

@asfbot
Copy link

asfbot commented Apr 27, 2017

Refer to this link for build results (access rights to CI server needed):
https://builds.apache.org/job/kafka-pr-jdk8-scala2.11/3212/
Test PASSed (JDK 8 and Scala 2.11).

@asfbot
Copy link

asfbot commented Apr 27, 2017

Refer to this link for build results (access rights to CI server needed):
https://builds.apache.org/job/kafka-pr-jdk8-scala2.12/3212/
Test FAILed (JDK 8 and Scala 2.12).

@asfbot
Copy link

asfbot commented Apr 27, 2017

Refer to this link for build results (access rights to CI server needed):
https://builds.apache.org/job/kafka-pr-jdk8-scala2.11/3220/
Test PASSed (JDK 8 and Scala 2.11).

/**
* Flush all state stores owned by this task
*/
void flushState() {
log.trace("{} Flushing state store", logPrefix);
Copy link
Contributor

Choose a reason for hiding this comment

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

I feel it is a bit misleading since it is not flushing a store, but the manager.

BTW, maybe it's better just to move

log.debug("{} Flushing all stores registered in the state manager", logPrefix);

out of the if condition inside manager.flush() and avoid adding this?

Copy link
Member Author

Choose a reason for hiding this comment

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

Well, it's that the same "thing" the manager is just an implementation details?
The idea is, to log that task.flushState() was called -- this log is independent of "how" the flushing is done. Does this make sense?

And I thinks it better to keep it within the if -> this los is not about a method got called, but what does actually happen -- and thus only log if an actual flush is done.

* @param writeCheckpoint boolean indicating if a checkpoint file should be written
*/
void closeStateManager(final boolean writeCheckpoint) throws ProcessorStateException {
log.trace("{} Closing state stores", logPrefix);
Copy link
Contributor

Choose a reason for hiding this comment

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

Ditto to my other comment, maybe we can just move

log.debug("{} Closing its state manager and all the registered state stores", logPrefix);

out of the if condition inside the manager code.

}

protected void updateOffsetLimits() {
log.trace("{} Updating store offset limits", logPrefix);
Copy link
Contributor

Choose a reason for hiding this comment

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

Change trace to debug?

Copy link
Member Author

@mjsax mjsax Apr 27, 2017

Choose a reason for hiding this comment

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

I'll change this to debug and do the inner as trace

Copy link
Contributor

Choose a reason for hiding this comment

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

Just trying to be consistent with other task-level log entries. We can also just remove this as you mentioned below.

initTopology();
@Override
protected void flushState() {
log.trace("{} Flushing state and producer topology", logPrefix);
Copy link
Contributor

Choose a reason for hiding this comment

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

producer topology -> producer?

@Override
protected void flushState() {
log.trace("{} Flushing state and producer topology", logPrefix);
super.flushState();
Copy link
Contributor

Choose a reason for hiding this comment

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

It will incur two trace logging one from stream-task and one from abstract-task if trace is enabled.

Instead could we just add a trace log after line 262 for "Flushing the producer after all state store has been flushed and corresponding changelog records sent".

Copy link
Member Author

Choose a reason for hiding this comment

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

same reply as above -- all those log indicate that a method got called -- thus it's not "double logging" imho -- but it's of course verbose, but for trace level should be fine

for (final TopicPartition partition : partitions) {
try {
final OffsetAndMetadata metadata = consumer.committed(partition); // TODO: batch API?
stateMgr.putOffsetLimit(partition, metadata != null ? metadata.offset() : 0L);
Copy link
Contributor

Choose a reason for hiding this comment

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

Add a trace entry recording the updated offset limit inside the manager class?

Copy link
Member Author

@mjsax mjsax Apr 27, 2017

Choose a reason for hiding this comment

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

Ack.

streamsMetrics = new StreamsMetricsThreadImpl(metrics, "stream-metrics", "thread." + threadClientId,
Collections.singletonMap("client-id", threadClientId));
if (config.getLong(StreamsConfig.CACHE_MAX_BYTES_BUFFERING_CONFIG) < 0) {
log.warn("Negative cache size passed in thread [{}]. Reverting to cache size of 0 bytes.", threadClientId);
log.warn("{} Negative cache size passed in thread [{}]. Reverting to cache size of 0 bytes.", logPrefix, threadClientId);
Copy link
Contributor

Choose a reason for hiding this comment

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

The second param seems redundant.

@@ -682,7 +781,7 @@ private void maybeUpdateStandbyTasks() {
final Map<TopicPartition, List<ConsumerRecord<byte[], byte[]>>> remainingStandbyRecords = new HashMap<>();

for (final Map.Entry<TopicPartition, List<ConsumerRecord<byte[], byte[]>>> entry :
standbyRecords.entrySet()) {
standbyRecords.entrySet()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This newline is not needed.

@@ -122,14 +105,14 @@ public void commit() {
*/
@Override
public void suspend() {
log.info("{} Suspending", logPrefix);
log.debug("{} Suspending", logPrefix);
Copy link
Contributor

Choose a reason for hiding this comment

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

Seems we are not actually?

for (final AbstractTask task : activeAndStandbytasks()) {
 +            try {
 +                task.suspend();
 +            } catch (final RuntimeException e) {
 +                firstException.compareAndSet(null, e);
 +            }
 +        }

@@ -939,6 +1209,7 @@ private void addStreamTasks(final Collection<TopicPartition> assignment, final l
final Map<TaskId, Set<TopicPartition>> newTasks = new HashMap<>();

// collect newly assigned tasks and reopen re-assigned tasks
log.info("{} Resuming suspended re-assigned tasks", logPrefix);
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems a bit misleading, and less informative. Maybe just "Adding active tasks {partitionAssignor.activeTasks()}"?

Ditto below for standby tasks

Copy link
Member Author

Choose a reason for hiding this comment

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

Why? Cf Line 1221 -> task.resume()
This loop figures out what resume task got reassigned.

@guozhangwang
Copy link
Contributor

retest this please

@asfbot
Copy link

asfbot commented Apr 27, 2017

Refer to this link for build results (access rights to CI server needed):
https://builds.apache.org/job/kafka-pr-jdk7-scala2.10/3236/
Test FAILed (JDK 7 and Scala 2.10).

@guozhangwang
Copy link
Contributor

@mjsax is Jenkins failure relevant?

@asfbot
Copy link

asfbot commented Apr 27, 2017

Refer to this link for build results (access rights to CI server needed):
https://builds.apache.org/job/kafka-pr-jdk8-scala2.11/3241/
Test FAILed (JDK 8 and Scala 2.11).

@mjsax
Copy link
Member Author

mjsax commented Apr 27, 2017

It says: :clients:findbugsMain FAILED

I'll try to rebase.

@mjsax mjsax force-pushed the kafka-5111-code-cleanup-follow-up branch from cd6cbea to 3f545d7 Compare April 27, 2017 23:18
@mjsax
Copy link
Member Author

mjsax commented Apr 27, 2017

Updated and rebased. \cc @guozhangwang

@asfbot
Copy link

asfbot commented Apr 27, 2017

Refer to this link for build results (access rights to CI server needed):
https://builds.apache.org/job/kafka-pr-jdk8-scala2.12/3232/
Test PASSed (JDK 8 and Scala 2.12).

@asfbot
Copy link

asfbot commented Apr 27, 2017

Refer to this link for build results (access rights to CI server needed):
https://builds.apache.org/job/kafka-pr-jdk7-scala2.10/3246/
Test FAILed (JDK 7 and Scala 2.10).

@guozhangwang
Copy link
Contributor

Merged to trunk.

@asfgit asfgit closed this in 6753af2 Apr 28, 2017
@mjsax mjsax deleted the kafka-5111-code-cleanup-follow-up branch April 28, 2017 00:48
@asfbot
Copy link

asfbot commented Apr 28, 2017

Refer to this link for build results (access rights to CI server needed):
https://builds.apache.org/job/kafka-pr-jdk7-scala2.10/3249/
Test PASSed (JDK 7 and Scala 2.10).

@asfbot
Copy link

asfbot commented Apr 28, 2017

Refer to this link for build results (access rights to CI server needed):
https://builds.apache.org/job/kafka-pr-jdk8-scala2.12/3245/
Test FAILed (JDK 8 and Scala 2.12).

@asfbot
Copy link

asfbot commented Apr 28, 2017

Refer to this link for build results (access rights to CI server needed):
https://builds.apache.org/job/kafka-pr-jdk8-scala2.11/3254/
Test FAILed (JDK 8 and Scala 2.11).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants