You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@uima.apache.org by "Marshall Schor (JIRA)" <ui...@incubator.apache.org> on 2008/08/21 22:23:44 UTC

[jira] Created: (UIMA-1153) thread safety issue with sample flow controller AdvancedFixedFlowController

thread safety issue with sample flow controller AdvancedFixedFlowController
---------------------------------------------------------------------------

                 Key: UIMA-1153
                 URL: https://issues.apache.org/jira/browse/UIMA-1153
             Project: UIMA
          Issue Type: Bug
          Components: Async Scaleout, Examples
    Affects Versions: 2.2.2
            Reporter: Marshall Schor
            Priority: Minor


The AdvancedFixedFlowController implements its Flow Object class as an inner class of its Flow Controller class.

In UIMA-AS, it is possible that more than one Flow Object can be accessing the Flow Controller fields on different threads, and (for Cas Multipliers) it is possible for an individual Flow Object to be called on multiple threads at the same time (via the method (via the newCasProduced method).  

In the example, the newCasProduced method is marked *synchronized*, so I think the same Flow Object will not be running multiple threads at the same time, because the other methods to this are all calls done on 1 thread on behalf of the main CAS associated with this Flow Object.

However, multiple flow objects running on different threads could have their newCasProduced method called.  In this case, the references in that method to common mutable fields in the shared Flow Controller object are not synchronized.  This code should be fixed so that those references are synchronized on the same monitor used to synchronize other field access in the Flow Controller.  UIMA-1149 I hope will use the class instance of the flow controller for this purpose, and, assuming that it does, this code should explicitly synchronize on that same object, for references to mutable fields in that class.  There is one field, mSequence, which is in the associated Flow Controller class, which is mutable (in theory).  References to this field should be synchronized with the same monitor used by the flow controller class when manipulating it.

The other field references in the flow object should be checked, and synchronized if they refer to mutable Flow Controller fields.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Assigned: (UIMA-1153) thread safety issue with sample flow controller AdvancedFixedFlowController

Posted by "Jerry Cwiklik (JIRA)" <ui...@incubator.apache.org>.
     [ https://issues.apache.org/jira/browse/UIMA-1153?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Jerry Cwiklik reassigned UIMA-1153:
-----------------------------------

    Assignee: Burn Lewis

> thread safety issue with sample flow controller AdvancedFixedFlowController
> ---------------------------------------------------------------------------
>
>                 Key: UIMA-1153
>                 URL: https://issues.apache.org/jira/browse/UIMA-1153
>             Project: UIMA
>          Issue Type: Bug
>          Components: Async Scaleout, Examples
>    Affects Versions: 2.2.2
>            Reporter: Marshall Schor
>            Assignee: Burn Lewis
>            Priority: Minor
>
> The AdvancedFixedFlowController implements its Flow Object class as an inner class of its Flow Controller class.
> In UIMA-AS, it is possible that more than one Flow Object can be accessing the Flow Controller fields on different threads, and (for Cas Multipliers) it is possible for an individual Flow Object to be called on multiple threads at the same time (via the method (via the newCasProduced method).  
> In the example, the newCasProduced method is marked *synchronized*, so I think the same Flow Object will not be running multiple threads at the same time, because the other methods to this are all calls done on 1 thread on behalf of the main CAS associated with this Flow Object.
> However, multiple flow objects running on different threads could have their newCasProduced method called.  In this case, the references in that method to common mutable fields in the shared Flow Controller object are not synchronized.  This code should be fixed so that those references are synchronized on the same monitor used to synchronize other field access in the Flow Controller.  UIMA-1149 I hope will use the class instance of the flow controller for this purpose, and, assuming that it does, this code should explicitly synchronize on that same object, for references to mutable fields in that class.  There is one field, mSequence, which is in the associated Flow Controller class, which is mutable (in theory).  References to this field should be synchronized with the same monitor used by the flow controller class when manipulating it.
> The other field references in the flow object should be checked, and synchronized if they refer to mutable Flow Controller fields.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (UIMA-1153) thread safety issue with sample flow controller AdvancedFixedFlowController

Posted by "Marshall Schor (JIRA)" <ui...@incubator.apache.org>.
    [ https://issues.apache.org/jira/browse/UIMA-1153?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12624480#action_12624480 ] 

Marshall Schor commented on UIMA-1153:
--------------------------------------

If UIMA-1149 is implemented such that no synchronization is needed because the framework implicitly will be locking calls to flow controller methods and flow object methods on the associated flow controller instance, then, this Jira should have as its action to simplify the examples by removing the synchronization - it will no longer be needed :-).

> thread safety issue with sample flow controller AdvancedFixedFlowController
> ---------------------------------------------------------------------------
>
>                 Key: UIMA-1153
>                 URL: https://issues.apache.org/jira/browse/UIMA-1153
>             Project: UIMA
>          Issue Type: Bug
>          Components: Async Scaleout, Examples
>    Affects Versions: 2.2.2
>            Reporter: Marshall Schor
>            Priority: Minor
>
> The AdvancedFixedFlowController implements its Flow Object class as an inner class of its Flow Controller class.
> In UIMA-AS, it is possible that more than one Flow Object can be accessing the Flow Controller fields on different threads, and (for Cas Multipliers) it is possible for an individual Flow Object to be called on multiple threads at the same time (via the method (via the newCasProduced method).  
> In the example, the newCasProduced method is marked *synchronized*, so I think the same Flow Object will not be running multiple threads at the same time, because the other methods to this are all calls done on 1 thread on behalf of the main CAS associated with this Flow Object.
> However, multiple flow objects running on different threads could have their newCasProduced method called.  In this case, the references in that method to common mutable fields in the shared Flow Controller object are not synchronized.  This code should be fixed so that those references are synchronized on the same monitor used to synchronize other field access in the Flow Controller.  UIMA-1149 I hope will use the class instance of the flow controller for this purpose, and, assuming that it does, this code should explicitly synchronize on that same object, for references to mutable fields in that class.  There is one field, mSequence, which is in the associated Flow Controller class, which is mutable (in theory).  References to this field should be synchronized with the same monitor used by the flow controller class when manipulating it.
> The other field references in the flow object should be checked, and synchronized if they refer to mutable Flow Controller fields.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (UIMA-1153) thread safety issue with sample flow controller AdvancedFixedFlowController

Posted by "Marshall Schor (JIRA)" <ui...@incubator.apache.org>.
    [ https://issues.apache.org/jira/browse/UIMA-1153?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12624471#action_12624471 ] 

Marshall Schor commented on UIMA-1153:
--------------------------------------

Also check other flow controller examples, and update documentation

> thread safety issue with sample flow controller AdvancedFixedFlowController
> ---------------------------------------------------------------------------
>
>                 Key: UIMA-1153
>                 URL: https://issues.apache.org/jira/browse/UIMA-1153
>             Project: UIMA
>          Issue Type: Bug
>          Components: Async Scaleout, Examples
>    Affects Versions: 2.2.2
>            Reporter: Marshall Schor
>            Priority: Minor
>
> The AdvancedFixedFlowController implements its Flow Object class as an inner class of its Flow Controller class.
> In UIMA-AS, it is possible that more than one Flow Object can be accessing the Flow Controller fields on different threads, and (for Cas Multipliers) it is possible for an individual Flow Object to be called on multiple threads at the same time (via the method (via the newCasProduced method).  
> In the example, the newCasProduced method is marked *synchronized*, so I think the same Flow Object will not be running multiple threads at the same time, because the other methods to this are all calls done on 1 thread on behalf of the main CAS associated with this Flow Object.
> However, multiple flow objects running on different threads could have their newCasProduced method called.  In this case, the references in that method to common mutable fields in the shared Flow Controller object are not synchronized.  This code should be fixed so that those references are synchronized on the same monitor used to synchronize other field access in the Flow Controller.  UIMA-1149 I hope will use the class instance of the flow controller for this purpose, and, assuming that it does, this code should explicitly synchronize on that same object, for references to mutable fields in that class.  There is one field, mSequence, which is in the associated Flow Controller class, which is mutable (in theory).  References to this field should be synchronized with the same monitor used by the flow controller class when manipulating it.
> The other field references in the flow object should be checked, and synchronized if they refer to mutable Flow Controller fields.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (UIMA-1153) thread safety issue with sample flow controller AdvancedFixedFlowController

Posted by "Marshall Schor (JIRA)" <ui...@incubator.apache.org>.
    [ https://issues.apache.org/jira/browse/UIMA-1153?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12767074#action_12767074 ] 

Marshall Schor commented on UIMA-1153:
--------------------------------------

I looked at the example code:  AdvancedControllerImplBase.  It implements some methods that are not in the FlowController interface, but rather in the Flow interface, such as newCasProduced.

In looking at the callers of this, I found they are synchronized, except maybe for one: the processUntilNextOutputCas() in ASB_impl$AggregateCasIterator.

Does this method need to synchronize on the same object that the others are synchronizing on?  (or are all of its callers doing that - I couldn't easily tell?)

> thread safety issue with sample flow controller AdvancedFixedFlowController
> ---------------------------------------------------------------------------
>
>                 Key: UIMA-1153
>                 URL: https://issues.apache.org/jira/browse/UIMA-1153
>             Project: UIMA
>          Issue Type: Bug
>          Components: Async Scaleout, Examples
>    Affects Versions: 2.2.2
>            Reporter: Marshall Schor
>            Assignee: Burn Lewis
>            Priority: Minor
>
> The AdvancedFixedFlowController implements its Flow Object class as an inner class of its Flow Controller class.
> In UIMA-AS, it is possible that more than one Flow Object can be accessing the Flow Controller fields on different threads, and (for Cas Multipliers) it is possible for an individual Flow Object to be called on multiple threads at the same time (via the method (via the newCasProduced method).  
> In the example, the newCasProduced method is marked *synchronized*, so I think the same Flow Object will not be running multiple threads at the same time, because the other methods to this are all calls done on 1 thread on behalf of the main CAS associated with this Flow Object.
> However, multiple flow objects running on different threads could have their newCasProduced method called.  In this case, the references in that method to common mutable fields in the shared Flow Controller object are not synchronized.  This code should be fixed so that those references are synchronized on the same monitor used to synchronize other field access in the Flow Controller.  UIMA-1149 I hope will use the class instance of the flow controller for this purpose, and, assuming that it does, this code should explicitly synchronize on that same object, for references to mutable fields in that class.  There is one field, mSequence, which is in the associated Flow Controller class, which is mutable (in theory).  References to this field should be synchronized with the same monitor used by the flow controller class when manipulating it.
> The other field references in the flow object should be checked, and synchronized if they refer to mutable Flow Controller fields.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (UIMA-1153) thread safety issue with sample flow controller AdvancedFixedFlowController

Posted by "Burn Lewis (JIRA)" <ui...@incubator.apache.org>.
    [ https://issues.apache.org/jira/browse/UIMA-1153?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12761732#action_12761732 ] 

Burn Lewis commented on UIMA-1153:
----------------------------------

A nice solution ... we should change the FC example ... but may be hard to test .. can FindBugs help us?

> thread safety issue with sample flow controller AdvancedFixedFlowController
> ---------------------------------------------------------------------------
>
>                 Key: UIMA-1153
>                 URL: https://issues.apache.org/jira/browse/UIMA-1153
>             Project: UIMA
>          Issue Type: Bug
>          Components: Async Scaleout, Examples
>    Affects Versions: 2.2.2
>            Reporter: Marshall Schor
>            Assignee: Burn Lewis
>            Priority: Minor
>
> The AdvancedFixedFlowController implements its Flow Object class as an inner class of its Flow Controller class.
> In UIMA-AS, it is possible that more than one Flow Object can be accessing the Flow Controller fields on different threads, and (for Cas Multipliers) it is possible for an individual Flow Object to be called on multiple threads at the same time (via the method (via the newCasProduced method).  
> In the example, the newCasProduced method is marked *synchronized*, so I think the same Flow Object will not be running multiple threads at the same time, because the other methods to this are all calls done on 1 thread on behalf of the main CAS associated with this Flow Object.
> However, multiple flow objects running on different threads could have their newCasProduced method called.  In this case, the references in that method to common mutable fields in the shared Flow Controller object are not synchronized.  This code should be fixed so that those references are synchronized on the same monitor used to synchronize other field access in the Flow Controller.  UIMA-1149 I hope will use the class instance of the flow controller for this purpose, and, assuming that it does, this code should explicitly synchronize on that same object, for references to mutable fields in that class.  There is one field, mSequence, which is in the associated Flow Controller class, which is mutable (in theory).  References to this field should be synchronized with the same monitor used by the flow controller class when manipulating it.
> The other field references in the flow object should be checked, and synchronized if they refer to mutable Flow Controller fields.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.