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

Add retry to make sure source is not shutdown when exceptions are thrown on the main thread #5029

Merged
merged 2 commits into from
Oct 11, 2024

Conversation

sb2k16
Copy link
Member

@sb2k16 sb2k16 commented Oct 8, 2024

Description

It has been observed that If the pipeline role is missing Kinesis permissions, the source throws an exception resulting in a shutdown of the pipeline.
The fix is to add retry based on 2 configurations in KinesisSource:

  • max_initialization_attempts - to allow the customer to continue retry to initialize the source
  • initialization_backoff_time - wait between retry calls

This should help to make sure that the pipeline is not terminated when permissions are missing. With updated permissions, the pipeline should continue to initialize and function properly.

Issues Resolved

Resolves #1082

Check List

  • New functionality includes testing.
  • Commits are signed with a real name per the DCO

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

@@ -116,6 +116,11 @@ public void start(final Buffer<Record<Event>> buffer) {
public void shutDown() {
LOG.info("Stop request received for Kinesis Source");

if (scheduler == null) {
LOG.info("Scheduler not initialized!!");
Copy link
Member

Choose a reason for hiding this comment

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

Let's avoid using exclamation marks unless we really need them.

Suggested change
LOG.info("Scheduler not initialized!!");
LOG.info("The Kinesis Scheduler was not initialized.");

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks @dlvenable . I have addressed this.

@@ -116,6 +116,11 @@ public void start(final Buffer<Record<Event>> buffer) {
public void shutDown() {
LOG.info("Stop request received for Kinesis Source");

if (scheduler == null) {
LOG.info("Scheduler not initialized!!");
return;
Copy link
Member

Choose a reason for hiding this comment

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

I'm a little concerned about returning in this case. It may lead to errors down the line where we don't shut down other resources.

I tend to think this could would be better off with:

if(scheduler != null) {
  // shutdown
} else {
 // log
}

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks @dlvenable . I have addressed this.

try {
Thread.sleep(kinesisSourceConfig.getInitializationBackoffTime().toMillis());
} catch (InterruptedException e){
LOG.debug("Interrupted exception!");
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
LOG.debug("Interrupted exception!");
LOG.debug("Interrupted exception.");

@kkondaka kkondaka merged commit a49e93f into opensearch-project:main Oct 11, 2024
47 checks passed
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.

Support AWS Kinesis Data Streams as a Source
4 participants