Repository navigation
fix(batch): make batch failure tracking thread-safe for parallel processing - #2735
Conversation
6784aaa to
4c2d32a
Compare
|
I presume duplication is not a blocker for this—the reported code blocks were already duplicates, and resolving this would require a refactor effort which would be too big for a "fix" PR. @phipag, can we move forward with this or would you like me to try and resolve the duplication? |
|
Hey @bubanko, the Sonar duplication is acceptable here. But can you take a look at the |
4c2d32a to
1747296
Compare
|
Ah, yes. I don't know why I though the As for the unused |
…essing Replicate the thread-safe `BatchItemFailure` collection implementation from the `processBatchInParallel(event, context)` method to the overloaded variant that additionally accepting an executor. Apply this fix to all three `BatchMessageHandler` implementations. Using a shared, unsynchronized `ArrayList` to collect `BatchItemFailure` instances can lead to lost failure items or cause a worker thread to fail with an `ArrayOutOfBoundsException` due to concurrent modifications corrupting the list's internals state. GitHub issue number: aws-powertools#2712
1747296 to
530ead1
Compare
|
phipag
left a comment
There was a problem hiding this comment.
Thanks @bubanko,
I tested this again locally:
- Unit tests fail before the code change (not consistently but consistently enough for a regression test)
- E2E tests pass (I ran this against my AWS account)
This PR is ready to be merged. Thank you for your contribution!


Summary
Changes
Replicate the thread-safe
BatchItemFailurecollection implementation from theprocessBatchInParallel(event, context)method to the overloaded variant that additionally accepting an executor.Apply this fix to all three
BatchMessageHandlerimplementations.Using a shared, unsynchronized
ArrayListto collectBatchItemFailureinstances can lead to lost failure items or cause a worker thread to fail with anArrayOutOfBoundsExceptiondue to concurrent modifications corrupting the list's internals state.Issue number: Fixes #2712
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
Disclaimer: We value your time and bandwidth. As such, any pull requests created on non-triaged issues might not be successful.