I’m not quite clear on your use case.  Can you provide more details such as:

Is the function being invoked concurrently by different clients and/or threads? 
 
What is the shared state?  
Is the shared state local to the server or distributed across the entire 
cluster?  
Is the function invoked on a partitioned region, replicated region, etc?

In general, any time a function reads or writes shared state you need to 
control access to that data structure.  For example, if the shared state is a 
local counter that increments every time the function is invoked you could use 
the java.util.concurrency primitives.  If the counter was shared, you could use 
the Distributed Lock Service to control access (of course this would be an 
anti-pattern since that would serialize updates throughout the cluster).

Another general principle is to keep the critical, synchronized code block as 
short as possible to improve concurrency.

If you’re concerned about concurrent updates to _region_ entries you might look 
into transactions.

Anthony


> On Feb 27, 2020, at 3:25 AM, aashish choudhary <[email protected]> 
> wrote:
> 
> No-one?
> We ended up synchronising execute method call. Is this a good approach 
> tonthis solution?
> 
> 
> With best regards,
> Ashish
> 
> On Tue, Feb 25, 2020, 11:42 PM aashish choudhary 
> <[email protected] <mailto:[email protected]>> wrote:
> We are suspecting that during call to execute method when we get arguments 
> that time shared state of request object is running into threading issue. Is 
> that one of the possibility?
> 
> With best regards,
> Ashish
> 
> On Tue, Feb 25, 2020, 4:32 PM aashish choudhary <[email protected] 
> <mailto:[email protected]>> wrote:
> We are experiencing some threading issue while executing function with 
> multiple threads. Although documents says that execute method needs to be 
> thread safe. 
> https://geode.apache.org/releases/latest/javadoc/org/apache/geode/cache/execute/Function.html
>  
> <https://geode.apache.org/releases/latest/javadoc/org/apache/geode/cache/execute/Function.html>
> 
> Will it not make the calls sequential and slow things down.?
> 
> Thoughts?
> 
> With best regards,
> Ashish

Reply via email to