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

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

                Author: ASF GitHub Bot
            Created on: 12/Aug/19 11:17
            Start Date: 12/Aug/19 11:17
    Worklog Time Spent: 10m 
      Work Description: sadovnychyi commented on pull request #9294: 
[BEAM-7917] Fix datastore writes failing on retry
URL: https://github.com/apache/beam/pull/9294#discussion_r312875823
 
 

 ##########
 File path: sdks/python/apache_beam/io/gcp/datastore/v1new/helper.py
 ##########
 @@ -99,6 +105,19 @@ def write_mutations(batch, throttler, rpc_stats_callback, 
throttle_delay=1):
     rpc_stats_callback(throttled_secs=throttle_delay)
 
   try:
+    try:
+      batch.begin()
+    except ValueError:
+      # batch has already been started previously (and failed),
+      # we need to build it again from scratch (BEAM-7917)
+      batch = get_client(batch.project, batch.namespace).batch()
+      for mutation_type, mutation_element in mutations:
 
 Review comment:
   *Maybe* we could reconstruct it from scratch by using 
[https://github.com/googleapis/google-cloud-python/blob/master/datastore/google/cloud/datastore/helpers.py#L105](https://github.com/googleapis/google-cloud-python/blob/master/datastore/google/cloud/datastore/helpers.py#L105)
 (or key_from_protobuf) assuming that we could get those from batch.mutations. 
Then we don't have to pass them explicitly but we will perform more 
encoding/decoding when errors occur. 
 
----------------------------------------------------------------
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: 293078)
    Time Spent: 1.5h  (was: 1h 20m)

> Python datastore v1new fails on retry
> -------------------------------------
>
>                 Key: BEAM-7917
>                 URL: https://issues.apache.org/jira/browse/BEAM-7917
>             Project: Beam
>          Issue Type: Bug
>          Components: io-py-gcp, runner-dataflow
>    Affects Versions: 2.14.0
>         Environment: Python 3.7 on Dataflow
>            Reporter: Dmytro Sadovnychyi
>            Assignee: Dmytro Sadovnychyi
>            Priority: Major
>              Labels: pull-request-available
>          Time Spent: 1.5h
>  Remaining Estimate: 0h
>
> Traceback (most recent call last):
>   File "apache_beam/runners/common.py", line 782, in 
> apache_beam.runners.common.DoFnRunner.process
>   File "apache_beam/runners/common.py", line 454, in 
> apache_beam.runners.common.SimpleInvoker.invoke_process
>   File 
> "/usr/local/lib/python3.7/site-packages/apache_beam/io/gcp/datastore/v1new/datastoreio.py",
>  line 334, in process
>     self._flush_batch()
>   File 
> "/usr/local/lib/python3.7/site-packages/apache_beam/io/gcp/datastore/v1new/datastoreio.py",
>  line 349, in _flush_batch
>     throttle_delay=util.WRITE_BATCH_TARGET_LATENCY_MS // 1000)
>   File "/usr/local/lib/python3.7/site-packages/apache_beam/utils/retry.py", 
> line 197, in wrapper
>     return fun(*args, **kwargs)
>   File 
> "/usr/local/lib/python3.7/site-packages/apache_beam/io/gcp/datastore/v1new/helper.py",
>  line 99, in write_mutations
>     batch.commit()
>   File 
> "/usr/local/lib/python3.7/site-packages/google/cloud/datastore/batch.py", 
> line 271, in commit
>     raise ValueError("Batch must be in progress to commit()")
> ValueError: Batch must be in progress to commit()



--
This message was sent by Atlassian JIRA
(v7.6.14#76016)

Reply via email to