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

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

                Author: ASF GitHub Bot
            Created on: 25/Sep/20 20:47
            Start Date: 25/Sep/20 20:47
    Worklog Time Spent: 10m 
      Work Description: lukecwik commented on a change in pull request #12934:
URL: https://github.com/apache/beam/pull/12934#discussion_r495223102



##########
File path: sdks/python/apache_beam/runners/worker/sdk_worker.py
##########
@@ -376,35 +385,76 @@ def get(self, instruction_id, bundle_descriptor_id):
 
     Moves the ``BundleProcessor`` from the inactive to the active cache.
     """
-    try:
-      # pop() is threadsafe
-      processor = self.cached_bundle_processors[bundle_descriptor_id].pop()
-    except IndexError:
-      processor = bundle_processor.BundleProcessor(
-          self.fns[bundle_descriptor_id],
-          self.state_handler_factory.create_state_handler(
-              self.fns[bundle_descriptor_id].state_api_service_descriptor),
-          self.data_channel_factory)
-    self.active_bundle_processors[

Review comment:
       The `pop` is thread safe but accessing 
`self.cached_bundle_processors[bundle_descriptor_id]` is not guaranteed to be 
so your right that some could be saved based upon your suggestion but it still 
requires a self.lock surrounding
   ```
   processor = self.cached_bundle_processors[bundle_descriptor_id].pop()
   ```
   
   which will lead to us acquiring the mutex twice for the case when there is a 
cached instance while the current imlementation only needs the mutex twice if 
we need to create the BundleProcessor.




----------------------------------------------------------------
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: 491425)
    Time Spent: 7.5h  (was: 7h 20m)

> Fix race where split/progress calls return "Unknown process bundle 
> instruction"
> -------------------------------------------------------------------------------
>
>                 Key: BEAM-10959
>                 URL: https://issues.apache.org/jira/browse/BEAM-10959
>             Project: Beam
>          Issue Type: Bug
>          Components: sdk-py-harness
>            Reporter: Luke Cwik
>            Assignee: Luke Cwik
>            Priority: P2
>          Time Spent: 7.5h
>  Remaining Estimate: 0h
>
> Currently there is a race where a BundleProcessor doesn't exist until another 
> thread picks up the task and inserts into the active set. This allows for 
> split/progress calls to happen and error out with "Unknown process bundle 
> instruction X".
> Since the control stream is ordered, we can guarantee that an uninitialized 
> BundleProcessor exists that can respond to this really early split/progress 
> calls.



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

Reply via email to