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

Fix race condition in SqsWorker when acknowledgements are enabled #3001

Merged
merged 8 commits into from
Jul 11, 2023

Conversation

kkondaka
Copy link
Collaborator

Description

Fix race condition in SqsWorker when acknowledgements are enabled
When E2E acknowledgements are enabled, S3 Source need to synchronize between the callback thread and the main thread because main thread may not have got chance to fully populate the waitingForAcknowledgements list

Resolves #3000

Issues Resolved

#3000

Check List

  • [ X] New functionality includes testing.
  • New functionality has been documented.
    • New functionality has javadoc added
  • [ X] 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.

Krishna Kondaka added 2 commits July 11, 2023 15:00
Copy link
Collaborator

@engechas engechas left a comment

Choose a reason for hiding this comment

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

Builds failing. Code LGTM minus 1 minor comment

@@ -226,6 +227,7 @@ && isEventBridgeEventTypeCreated(parsedMessage)) {
for (ParsedMessage parsedMessage : parsedMessagesToRead) {
List<DeleteMessageBatchRequestEntry> waitingForAcknowledgements = new ArrayList<>();
AcknowledgementSet acknowledgementSet = null;
AtomicBoolean acknowledgementSetReady = new AtomicBoolean(false);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Doesn't look like this is used anywhere

Signed-off-by: Krishna Kondaka <[email protected]>
@@ -84,6 +86,8 @@ public boolean isDone() {
if (Instant.now().isAfter(expiryTime)) {
if (callbackFuture != null) {
callbackFuture.cancel(true);
callbackFuture = null;
LOG.warn("AcknowledgementSet expired");
Copy link
Member

Choose a reason for hiding this comment

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

Is there any other data we can provide to make this useful if it happens? I'd imagine there may be a lot of these and they could be hard to understand.

Perhaps include the expiry time? Could we include the overall time?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I am expecting there shouldn't be a lot of these. Since we only support one source, the acknowledgement set and expiry time should be obvious. We could pass a name to AcknowledgementSetManager.create when we support multiple sources.

}
try {
Thread.sleep(10000);
} catch (Exception e){}
Copy link
Member

Choose a reason for hiding this comment

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

Are you expecting the thread to be interrupted? If you are not expecting this, then you can just let an interruption fail the test.

Thread.sleep(10000);

and update the method to throws Exception.

Krishna Kondaka added 4 commits July 11, 2023 18:37
Signed-off-by: Krishna Kondaka <[email protected]>
Signed-off-by: Krishna Kondaka <[email protected]>
Signed-off-by: Krishna Kondaka <[email protected]>
@kkondaka kkondaka merged commit 515cf61 into opensearch-project:main Jul 11, 2023
24 checks passed
@opensearch-trigger-bot
Copy link
Contributor

The backport to 2.3 failed:

The process '/usr/bin/git' failed with exit code 1

To backport manually, run these commands in your terminal:

# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-2.3 2.3
# Navigate to the new working tree
cd .worktrees/backport-2.3
# Create a new branch
git switch --create backport/backport-3001-to-2.3
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 515cf6114f5270f5f4fc94eba6bdd62e45659944
# Push it to GitHub
git push --set-upstream origin backport/backport-3001-to-2.3
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-2.3

Then, create a pull request where the base branch is 2.3 and the compare/head branch is backport/backport-3001-to-2.3.

kkondaka added a commit to kkondaka/kk-data-prepper-f2 that referenced this pull request Jul 11, 2023
…ensearch-project#3001)

* Fix race condition in SqsWorker when acknowledgements are enabled

Signed-off-by: Krishna Kondaka <[email protected]>

* Modified to do the synchronization in the acknowledgement set framework

Signed-off-by: Krishna Kondaka <[email protected]>

* Fixed failing tests

Signed-off-by: Krishna Kondaka <[email protected]>

* Removed unused variable

Signed-off-by: Krishna Kondaka <[email protected]>

* Addressed review comment and fixed failing tests

Signed-off-by: Krishna Kondaka <[email protected]>

* Addressed review comments

Signed-off-by: Krishna Kondaka <[email protected]>

* Fixed failing tests

Signed-off-by: Krishna Kondaka <[email protected]>

* Fixed checkStyle failure

Signed-off-by: Krishna Kondaka <[email protected]>

---------

Signed-off-by: Krishna Kondaka <[email protected]>
Co-authored-by: Krishna Kondaka <[email protected]>
(cherry picked from commit 515cf61)
kkondaka added a commit that referenced this pull request Jul 12, 2023
) (#3010)

* Fix race condition in SqsWorker when acknowledgements are enabled

Signed-off-by: Krishna Kondaka <[email protected]>

* Modified to do the synchronization in the acknowledgement set framework

Signed-off-by: Krishna Kondaka <[email protected]>

* Fixed failing tests

Signed-off-by: Krishna Kondaka <[email protected]>

* Removed unused variable

Signed-off-by: Krishna Kondaka <[email protected]>

* Addressed review comment and fixed failing tests

Signed-off-by: Krishna Kondaka <[email protected]>

* Addressed review comments

Signed-off-by: Krishna Kondaka <[email protected]>

* Fixed failing tests

Signed-off-by: Krishna Kondaka <[email protected]>

* Fixed checkStyle failure

Signed-off-by: Krishna Kondaka <[email protected]>

---------

Signed-off-by: Krishna Kondaka <[email protected]>
Co-authored-by: Krishna Kondaka <[email protected]>
(cherry picked from commit 515cf61)
chenqi0805 pushed a commit that referenced this pull request Jul 19, 2023
)

* Fix race condition in SqsWorker when acknowledgements are enabled

Signed-off-by: Krishna Kondaka <[email protected]>

* Modified to do the synchronization in the acknowledgement set framework

Signed-off-by: Krishna Kondaka <[email protected]>

* Fixed failing tests

Signed-off-by: Krishna Kondaka <[email protected]>

* Removed unused variable

Signed-off-by: Krishna Kondaka <[email protected]>

* Addressed review comment and fixed failing tests

Signed-off-by: Krishna Kondaka <[email protected]>

* Addressed review comments

Signed-off-by: Krishna Kondaka <[email protected]>

* Fixed failing tests

Signed-off-by: Krishna Kondaka <[email protected]>

* Fixed checkStyle failure

Signed-off-by: Krishna Kondaka <[email protected]>

---------

Signed-off-by: Krishna Kondaka <[email protected]>
Co-authored-by: Krishna Kondaka <[email protected]>
Signed-off-by: George Chen <[email protected]>
MaGonzalMayedo pushed a commit to MaGonzalMayedo/data-prepper that referenced this pull request Jul 25, 2023
…ensearch-project#3001)

* Fix race condition in SqsWorker when acknowledgements are enabled

Signed-off-by: Krishna Kondaka <[email protected]>

* Modified to do the synchronization in the acknowledgement set framework

Signed-off-by: Krishna Kondaka <[email protected]>

* Fixed failing tests

Signed-off-by: Krishna Kondaka <[email protected]>

* Removed unused variable

Signed-off-by: Krishna Kondaka <[email protected]>

* Addressed review comment and fixed failing tests

Signed-off-by: Krishna Kondaka <[email protected]>

* Addressed review comments

Signed-off-by: Krishna Kondaka <[email protected]>

* Fixed failing tests

Signed-off-by: Krishna Kondaka <[email protected]>

* Fixed checkStyle failure

Signed-off-by: Krishna Kondaka <[email protected]>

---------

Signed-off-by: Krishna Kondaka <[email protected]>
Co-authored-by: Krishna Kondaka <[email protected]>
Signed-off-by: Marcos Gonzalez Mayedo <[email protected]>
@kkondaka kkondaka deleted the s3-race-cond branch May 13, 2024 05:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] Race condition in S3 source when E2E acknowledgements enabled
3 participants