Skip to content

KAFKA-5003: StreamThread should catch InvalidTopicException#2747

Closed
mjsax wants to merge 5 commits intoapache:trunkfrom
mjsax:minor-fix-reset
Closed

KAFKA-5003: StreamThread should catch InvalidTopicException#2747
mjsax wants to merge 5 commits intoapache:trunkfrom
mjsax:minor-fix-reset

Conversation

@mjsax
Copy link
Copy Markdown
Member

@mjsax mjsax commented Mar 28, 2017

We should catch InvalidTopicException and not just NoOffsetForPartitionException. Also, we need to step through all partitions that might be affected and reset those.

@mjsax
Copy link
Copy Markdown
Member Author

mjsax commented Mar 28, 2017

Call for review @dguy @enothereska @bbejeck

@asfbot
Copy link
Copy Markdown

asfbot commented Mar 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/2437/
Test PASSed (JDK 8 and Scala 2.12).

@asfbot
Copy link
Copy Markdown

asfbot commented Mar 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/2437/
Test PASSed (JDK 7 and Scala 2.10).

@asfbot
Copy link
Copy Markdown

asfbot commented Mar 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/2441/
Test PASSed (JDK 8 and Scala 2.11).

@enothereska
Copy link
Copy Markdown
Contributor

@mjsax is there any test failing that we can use to check if this works as expected? Thanks.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit: maybe change method name to addToResetList since resetting does not occur here?

@bbejeck
Copy link
Copy Markdown
Member

bbejeck commented Mar 30, 2017

Should we update the KStreamsFineGrainedAutoResetIntegrationTest to include a case where an out of range offset is requested?

@bbejeck
Copy link
Copy Markdown
Member

bbejeck commented Mar 30, 2017

@mjsax 2 minor comments, otherwise LGTM

@mjsax mjsax force-pushed the minor-fix-reset branch from 5d0c52c to 37faac0 Compare March 31, 2017 01:30
@mjsax
Copy link
Copy Markdown
Member Author

mjsax commented Mar 31, 2017

Updated: renamed method and added test for OffsetOutOfRangeException

\cc @enothereska @dguy @bbejeck

@bbejeck
Copy link
Copy Markdown
Member

bbejeck commented Mar 31, 2017

thanks @mjsax - LGTM

@asfbot
Copy link
Copy Markdown

asfbot commented Mar 31, 2017

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

@asfbot
Copy link
Copy Markdown

asfbot commented Mar 31, 2017

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

@asfbot
Copy link
Copy Markdown

asfbot commented Mar 31, 2017

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

@guozhangwang
Copy link
Copy Markdown
Contributor

retest this please

@asfbot
Copy link
Copy Markdown

asfbot commented Mar 31, 2017

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

@asfbot
Copy link
Copy Markdown

asfbot commented Mar 31, 2017

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

@asfbot
Copy link
Copy Markdown

asfbot commented Mar 31, 2017

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

Copy link
Copy Markdown
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.

one minor comment otherwise LGTM

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

if (loggedTopics.add(topic)) {...}

@mjsax
Copy link
Copy Markdown
Member Author

mjsax commented Mar 31, 2017

Updated.

@asfbot
Copy link
Copy Markdown

asfbot commented Mar 31, 2017

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

@asfbot
Copy link
Copy Markdown

asfbot commented Mar 31, 2017

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

@asfbot
Copy link
Copy Markdown

asfbot commented Apr 1, 2017

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

@mjsax
Copy link
Copy Markdown
Member Author

mjsax commented Apr 2, 2017

Retest this please.

@asfbot
Copy link
Copy Markdown

asfbot commented Apr 2, 2017

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

@asfbot
Copy link
Copy Markdown

asfbot commented Apr 2, 2017

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

@asfbot
Copy link
Copy Markdown

asfbot commented Apr 2, 2017

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm thinking this block should be extracted to a method. It doesn't really have much to do with pollRequests and it would be nicer to read if there was a method like resetPositions or similar

@enothereska
Copy link
Copy Markdown
Contributor

@mjsax not sure why the checks are failing.

@mjsax mjsax changed the title MINOR: StreamThread should catch InvalidTopicException KAFKA-5003: StreamThread should catch InvalidTopicException Apr 3, 2017
@mjsax mjsax force-pushed the minor-fix-reset branch from c13436d to 7af4ded Compare April 3, 2017 16:28
@asfbot
Copy link
Copy Markdown

asfbot commented Apr 3, 2017

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

@asfbot
Copy link
Copy Markdown

asfbot commented Apr 3, 2017

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

@asfbot
Copy link
Copy Markdown

asfbot commented Apr 3, 2017

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

@mjsax mjsax force-pushed the minor-fix-reset branch from 7af4ded to ac3c9ee Compare April 3, 2017 16:35
@mjsax
Copy link
Copy Markdown
Member Author

mjsax commented Apr 3, 2017

@eno @dguy Updated. Also updated #2774
The build is quite unstable lately -- I did rebase this branch to get latest test fixed for trunk -- the other PR did have 3 green build (before the latest update). Hope it will pass now.

@asfbot
Copy link
Copy Markdown

asfbot commented Apr 3, 2017

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

@asfbot
Copy link
Copy Markdown

asfbot commented Apr 3, 2017

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

@asfbot
Copy link
Copy Markdown

asfbot commented Apr 3, 2017

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

Copy link
Copy Markdown
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.

LGTM

@enothereska
Copy link
Copy Markdown
Contributor

LGTM

Copy link
Copy Markdown
Member

@ijuma ijuma left a comment

Choose a reason for hiding this comment

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

Thanks for the PR, left a couple of questions.

consumer.seekToEnd(ex.partitions());
addToResetList(partition, seekToEnd, "stream-thread [%s] no custom setting defined for topic %s using original config %s for offset reset", "latest", loggedTopics);
}
log.info(String.format("stream-thread [%s] no custom setting defined for topic %s using original config %s for offset reset", this.getName(), partition.topic(), originalReset));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why did we remove this log line? And what is the behaviour if there's no reset policy defined?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It is logged in addToResetList. In StreamsConfig we default the reset policy to earliest

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Having a second look, it seems that we throw an exception if the reset policy is not one of the expected values:

if (originalReset == null || (!originalReset.equals("earliest") && !originalReset.equals("latest"))) {

So the code can never reach this line.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

We can reach this line: there are two places the config can be set: globally (called originalReset here) and locally per topic. Thus, this exception here, only happens if both are invalid. We check the originalReset only, if no topic-local setting was specified.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I am not sure you understood my comment. I am suggesting that the line where the log.info was removed can never be reached. Are you saying that it can be reached?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yes. The old line (555) was hit, when no topic-level offset-strategy was specified, but a global one. Note, in Streams, we "remember" the global config but don't provide it to the consumer -- we set consumer strategy to none always to allow for different topic-level reset strategy in the first place (ie, we apply the global one "manually" within Streams)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@mjsax I think @ijuma is right in that line 555 was never reached.
I guess we're removing it anyway now.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks all, I think I now understand the misunderstanding.

final KStream<String, String> namedTopicsStream = builder.stream(TOPIC_Y, TOPIC_Z);
final KStream<String, String> pattern1Stream = builder.stream(KStreamBuilder.AutoOffsetReset.EARLIEST, Pattern.compile("topic-\\d_1"));
final KStream<String, String> pattern2Stream = builder.stream(KStreamBuilder.AutoOffsetReset.LATEST, Pattern.compile("topic-[A-D]_1"));
final KStream<String, String> namedTopicsStream = builder.stream(TOPIC_Y_1, TOPIC_Z_1);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Are these implicitly set to EARLIEST? If so, probably worth adding a comment. Same for the other test. Also, do we test the case where the original config is latest or not set?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

They are set to whatever is set in StreamsConfig, default is earliest.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Don't think a comment is required. Streams people know that default is earliest.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The point is making it clear what is being tested. Anyway, you didn't reply to the second question: "Also, do we test the case where the original config is latest or not set?"

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

We don't have a test -- can add one.

@mjsax
Copy link
Copy Markdown
Member Author

mjsax commented Apr 5, 2017

@ijuma Thanks for talking a look. Did reply.

@mjsax
Copy link
Copy Markdown
Member Author

mjsax commented Apr 6, 2017

@ijuma Added one more test.

@asfbot
Copy link
Copy Markdown

asfbot commented Apr 6, 2017

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

@asfbot
Copy link
Copy Markdown

asfbot commented Apr 6, 2017

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

@asfbot
Copy link
Copy Markdown

asfbot commented Apr 6, 2017

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

namedTopicsStream.to(stringSerde, stringSerde, DEFAULT_OUTPUT_TOPIC);
pattern1Stream.print();
pattern2Stream.print();
namedTopicsStream.print();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is this intentional? cc @enothereska

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks like it's for debugging. @mjsax ?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

OK, will remove before merging.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Thx. Missed to remove it...

@asfgit asfgit closed this in afeadbe Apr 6, 2017
@ijuma
Copy link
Copy Markdown
Member

ijuma commented Apr 6, 2017

LGTM, merged to trunk.

@mjsax mjsax deleted the minor-fix-reset branch April 7, 2017 03:18
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.

7 participants