[ 
https://issues.apache.org/jira/browse/BEAM-10706?focusedWorklogId=476598&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-476598
 ]

ASF GitHub Bot logged work on BEAM-10706:
-----------------------------------------

                Author: ASF GitHub Bot
            Created on: 31/Aug/20 14:30
            Start Date: 31/Aug/20 14:30
    Worklog Time Spent: 10m 
      Work Description: dennisylyung commented on a change in pull request 
#12583:
URL: https://github.com/apache/beam/pull/12583#discussion_r480169412



##########
File path: 
sdks/java/io/amazon-web-services/src/main/java/org/apache/beam/sdk/io/aws/dynamodb/DynamoDBIO.java
##########
@@ -450,12 +459,35 @@ public void startBundle(StartBundleContext context) {
       public void processElement(ProcessContext context) throws Exception {
         final KV<String, WriteRequest> writeRequest =
             (KV<String, WriteRequest>) 
spec.getWriteItemMapperFn().apply(context.element());
+        if (spec.getOverwriteByPKeys() != null) {
+          removeDupPKeysRequestsIfAny(writeRequest.getValue());
+        }
         batch.add(writeRequest);
         if (batch.size() >= BATCH_SIZE) {
           flushBatch();
         }
       }
 
+      private void removeDupPKeysRequestsIfAny(WriteRequest request) {

Review comment:
       I think the later event is more preferred, although Apache beam do not 
have strict ordering. Not sure why the AWS Python SDK is implemented this way. 
I will try using something like a map. 




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Issue Time Tracking
-------------------

    Worklog Id:     (was: 476598)
    Time Spent: 1h 10m  (was: 1h)

> DynamoDBIO fail to write to the same key in short consecution
> -------------------------------------------------------------
>
>                 Key: BEAM-10706
>                 URL: https://issues.apache.org/jira/browse/BEAM-10706
>             Project: Beam
>          Issue Type: Bug
>          Components: io-java-aws
>    Affects Versions: 2.23.0
>            Reporter: Dennis Yung
>            Assignee: Dennis Yung
>            Priority: P2
>          Time Spent: 1h 10m
>  Remaining Estimate: 0h
>
> Internally, DynamoDBIO.Write uses the batchWriteItem method from the AWS SDK 
> to sink items. However, there is a limitation in the AWS SDK that a call to 
> batchWriteItem cannot contain duplicate keys.
> Currently DynamoDBIO.Write performs no key deduplication before flushing a 
> batch, which could cause ValidationException: Provided list of item keys 
> contains duplicates, if consecutive updates to a single key is within the 
> batch size (currently hardcoded to be 25). 
> To fix this bug, the batch of write requests need to be deduplicated before 
> being sent to batchRequest.addRequestItemsEntry



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to