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

DBZ-7032 Implement Retries for Amazon Kinesis Event Transmittion #43

Conversation

ilyasahsan123
Copy link
Contributor

@ilyasahsan123 ilyasahsan123 commented Oct 13, 2023

@ilyasahsan123 ilyasahsan123 force-pushed the DBZ-7032-feat-retry-kinesis-debezium-server branch from 170d82e to b610ffa Compare October 13, 2023 14:50
Copy link
Member

@vjuranek vjuranek 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 you PR @ilyasahsan123 ! This needs few changes to make it working as you like.

@@ -86,6 +97,12 @@ void connect() {
LOGGER.info("Using default KinesisClient '{}'", client);
}

@VisibleForTesting
Copy link
Member

Choose a reason for hiding this comment

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

there are no tests for this method, so no need to mark is @VisibleForTesting and making public

@@ -86,6 +97,12 @@ void connect() {
LOGGER.info("Using default KinesisClient '{}'", client);
}

@VisibleForTesting
void initWithConfig(Config config) {
Copy link
Member

Choose a reason for hiding this comment

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

this method is actually not called anywhere, so it won't do anything

@@ -101,6 +118,23 @@ public void handleBatch(List<ChangeEvent<Object, Object>> records, RecordCommitt
throws InterruptedException {
for (ChangeEvent<Object, Object> record : records) {
LOGGER.trace("Received event '{}'", record);

int attempts = 0;
if (!recordSent(record)) {
Copy link
Member

Choose a reason for hiding this comment

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

@@ -112,8 +146,10 @@ public void handleBatch(List<ChangeEvent<Object, Object>> records, RecordCommitt
.data(SdkBytes.fromByteArray(getBytes(rv)))
.build();
client.putRecord(putRecord);
committer.markProcessed(record);
} catch (SdkClientException exception) {
LOGGER.error("Failed to send record to {}:", record.destination(), exception);
Copy link
Member

Choose a reason for hiding this comment

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

No need to log the exception and re-throw. Either you should handle the exception and if you don't handle it, don't catch it a let the caller to handle it (and eventually log the exception)

1. Remove unused variables.
2. Remove unused function.
3. Enhance the function to handle batch.
Copy link
Member

@vjuranek vjuranek left a comment

Choose a reason for hiding this comment

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

thanks, LGTM now @ilyasahsan123 !

@@ -55,6 +60,8 @@ public class KinesisChangeConsumer extends BaseChangeConsumer implements Debeziu
private String region;
private Optional<String> endpointOverride;
private Optional<String> credentialsProfile;
private static final int DEFAULT_RETRIES = 5;
private static final Long RETRY_INTERVAL = Integer.toUnsignedLong(1_000);

Copy link
Contributor

Choose a reason for hiding this comment

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

It would be interesting if the DEFAULT_RETRIES and RETRY_INTERVAL were config properties. Something like debezium.sink.kinesis.default.retries and debezium.sink.kinesis.retry.interval. WDYT?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

[CMIIW] I am not sure about this; it's technically possible, but in my opinion, it's not necessary. If we take a look at other sinks:

  1. For HTTP, the retries are hardcoded to 5.
  2. For EventHub, the client uses the default retries, which is 9 times.

The exception is Pub/Sub, where the retry properties can be dynamically set via properties.

Do you have any comment @vjuranek?

Copy link
Contributor

Choose a reason for hiding this comment

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

Let's start with hard-coded values only and a separate Jira that would make it configurable for all sinks should be created to make it consistent.

@vjuranek
Copy link
Member

@ilyasahsan123 the CI fails due to wrong formatting. Could you please take a look and fix it (I guess something like mvn -f server/debezium-server-kinesis net.revelc.code.formatter:formatter-maven-plugin:2.20.0:format should do the job). Thanks!

@ilyasahsan123
Copy link
Contributor Author

@ilyasahsan123 the CI fails due to wrong formatting. Could you please take a look and fix it (I guess something like mvn -f server/debezium-server-kinesis net.revelc.code.formatter:formatter-maven-plugin:2.20.0:format should do the job). Thanks!

hi @vjuranek, thanks for the suggestion. I have formatted the code. Could you please take a look? thanks

@jpechane jpechane force-pushed the DBZ-7032-feat-retry-kinesis-debezium-server branch from 3783994 to 4727862 Compare October 30, 2023 09:56
@jpechane jpechane merged commit f69c2e6 into debezium:main Oct 30, 2023
1 of 2 checks passed
@jpechane
Copy link
Contributor

@ilyasahsan123 LGTM, apliied. Thanks!

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