Skip to content

Conversation

@dcfocus
Copy link
Contributor

@dcfocus dcfocus commented Nov 15, 2019

This PR improves Kafka connector implementation and performance.

  1. Replaced SimpleConsumer with KafkaConsumer for Kafka connector.
  2. Push collecting offsets for each partition from coordinator to workers to resolve the bottleneck.

@dcfocus
Copy link
Contributor Author

dcfocus commented Nov 15, 2019

@rongrong @zhenxiao
Refactored previous PR, this one is the main one with upgrading Kafka client. Other features will come later, including nested ROW type support and zookeeper discovery, etc.

Copy link
Collaborator

@zhenxiao zhenxiao left a comment

Choose a reason for hiding this comment

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

thank you, @dcfocus
I add some comments

Copy link
Collaborator

Choose a reason for hiding this comment

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

s/offset_start_ts/startOffsetTimestamp/g
generally, we do not put underscore in toString

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

@dcfocus dcfocus requested a review from zhenxiao November 29, 2019 01:45
@dcfocus
Copy link
Contributor Author

dcfocus commented Nov 29, 2019

Hi @zhenxiao Thanks for all the comments. Very helpful!!
I fixed most of the comments and left explanation for the rest.
Can you take a look once you get time?
(Current build failed due to time exception of 1 hour 20 min. Will pass if re-run. But seems Travis doesn't allow re-run. )

pom.xml Outdated

Choose a reason for hiding this comment

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

Any reason this isn't higher?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Was to keep consistent with kafka_2.12

Choose a reason for hiding this comment

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

I'm not sure there's a correlation between the Scala version and Kafka version.

If Presto needs Scala 2.12, that's fine, but I mean, why not target Kafka 2.3.0, the latest version, for example?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks Jordan for explanation. Yes, you are right. There shouldn't be correlation. I will update to latest compatible version.

Copy link
Collaborator

Choose a reason for hiding this comment

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

same question, shall we use kafka 2.3.1, the latest version?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right, but I keep running into this issue after I tried with 2.0.0+
Caused by: java.lang.ClassNotFoundException: org.apache.kafka.common.record.RecordFormat

Choose a reason for hiding this comment

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

Should these be ByteBuffer if that's your deserializer type?

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 catch. Thanks for pointing out.

Choose a reason for hiding this comment

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

Should you add <ByteBuffer, ByteBuffer>?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

Choose a reason for hiding this comment

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

Are types needed here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

@dcfocus
Copy link
Contributor Author

dcfocus commented Dec 4, 2019

This PR improves Kafka connector implementation and performance.

  1. Replaced SimpleConsumer with KafkaConsumer for Kafka connector.
  2. Push collecting offsets for each partition from coordinator to workers to resolve the bottleneck.

Removed change 2 after discussion with @zhenxiao . For most companies, kafka topic is not that big, we may not have significant performance gain from pushdown of getOffsetByTimeStamp.

Copy link
Collaborator

@zhenxiao zhenxiao left a comment

Choose a reason for hiding this comment

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

thank you, @dcfocus
A few more comments

Copy link
Collaborator

Choose a reason for hiding this comment

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

s/props/properties/g

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

Copy link
Collaborator

Choose a reason for hiding this comment

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

s/props/properties/g ?

Copy link
Collaborator

Choose a reason for hiding this comment

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

static import these ConsumerConfig constants

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

Copy link
Collaborator

Choose a reason for hiding this comment

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

why set classloader to null?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed. Was there to get ride of some exception during experiments.

Copy link
Collaborator

Choose a reason for hiding this comment

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

use Thread.currentThread().getName(), instead of creating threadId

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I still feel 1s is too long, how about 500ms?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

Copy link
Collaborator

Choose a reason for hiding this comment

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

use thread getName(), instead of getId()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

Copy link
Collaborator

Choose a reason for hiding this comment

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

would it better return a pair of long? instead of having a long array?
Or, we could inline this functions

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. Inlined, fixed.

Copy link
Collaborator

Choose a reason for hiding this comment

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

move this line above the for loop

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

Copy link
Collaborator

Choose a reason for hiding this comment

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

do we need KafkaCluster interface? It only has one implementation
we might just need one class with selectRandomServer()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

pom.xml Outdated
Copy link
Collaborator

Choose a reason for hiding this comment

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

same question, shall we use kafka 2.3.1, the latest version?

Copy link
Collaborator

@zhenxiao zhenxiao left a comment

Choose a reason for hiding this comment

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

almost there, thank you @dcfocus
please update documentation:
./presto-docs/src/main/sphinx/connector/kafka.rst
./presto-docs/src/main/sphinx/connector/kafka-tutorial.rst

And your PR title should be: "Update Kafka connector to 2.3.1"

Copy link
Collaborator

Choose a reason for hiding this comment

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

s/props/properties/g ?

Copy link
Collaborator

Choose a reason for hiding this comment

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

no need to move leader here, is it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

@zhenxiao
Copy link
Collaborator

zhenxiao commented Dec 6, 2019

Hi @Cricket007 upon tests passed, am mostly good with this PR
could you please do one more pass before I merge?

@dcfocus dcfocus changed the title Update Kafka Connector Update Kafka connector to 2.3.1 Dec 6, 2019
Copy link

@OneCricketeer OneCricketeer left a comment

Choose a reason for hiding this comment

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

Mostly satisfied ✅

Minor comments

pom.xml Outdated

Choose a reason for hiding this comment

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

Could we extract this version as a property?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

Choose a reason for hiding this comment

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

Default partitioner is default. Need to specify?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed. Thanks for catching this one.

@dcfocus
Copy link
Contributor Author

dcfocus commented Dec 6, 2019

Hi @Cricket007 upon tests passed, am mostly good with this PR
could you please do one more pass before I merge?

Thanks to both. Very helpful comments.
One more change added: the notion segment is deprecated. I removed the related code in this commit.

Copy link
Collaborator

@zhenxiao zhenxiao left a comment

Choose a reason for hiding this comment

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

good to me
a few minor issues

pom.xml Outdated
Copy link
Collaborator

Choose a reason for hiding this comment

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

kafka.version

pom.xml Outdated
Copy link
Collaborator

Choose a reason for hiding this comment

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

just use kafka.version, no need to create a separate clients version

Copy link
Collaborator

Choose a reason for hiding this comment

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

Apache kafka 2.3.1+ is supported

Copy link
Collaborator

Choose a reason for hiding this comment

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

1024Kb * 1024 = 1MB?

Copy link
Collaborator

@zhenxiao zhenxiao left a comment

Choose a reason for hiding this comment

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

looks good to me
upon test passed, I will merge

Copy link
Collaborator

@zhenxiao zhenxiao left a comment

Choose a reason for hiding this comment

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

one more comment

pom.xml Outdated
Copy link
Collaborator

Choose a reason for hiding this comment

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

could we add this dependency to presto-kafka/pom.xml?

@zhenxiao
Copy link
Collaborator

@dcfocus could you please fix the test failures?

@dcfocus
Copy link
Contributor Author

dcfocus commented Jan 18, 2020

@dcfocus could you please fix the test failures?

Hi @zhenxiao The maximum run time for each check is limited to 1 hour 20 min. Sometimes it will finish within that limit. It doesn't allow me to re-run. Can you re-run it on your side?

Copy link
Collaborator

Choose a reason for hiding this comment

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

why are we making these changes? this is for presto-server, better not to pollute the lib

@dcfocus dcfocus force-pushed the oss-multi-commits/upgrade-to-kafkaconsumer branch from 523e809 to 8f77144 Compare January 22, 2020 22:00
@dcfocus dcfocus changed the base branch from release-0.228 to master January 22, 2020 22:08
@dcfocus dcfocus force-pushed the oss-multi-commits/upgrade-to-kafkaconsumer branch from 8f77144 to 687dc04 Compare January 22, 2020 22:28

Choose a reason for hiding this comment

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

I see nothing wrong with try with resources

@dcfocus dcfocus force-pushed the oss-multi-commits/upgrade-to-kafkaconsumer branch 7 times, most recently from b6198ce to 1ac3805 Compare January 29, 2020 01:21
@dcfocus dcfocus force-pushed the oss-multi-commits/upgrade-to-kafkaconsumer branch from 1ac3805 to 1dd8354 Compare January 29, 2020 09:26
@zhenxiao zhenxiao merged commit 8eb0192 into prestodb:master Jan 30, 2020
@caithagoras caithagoras mentioned this pull request Feb 20, 2020
8 tasks
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.

4 participants