Pivotal Knowledge Base


Function gets Executed Twice on Server with Gateway Receiver if Groups are Configured


 Product  Version
 Pivotal GemFire  7.x -
 OS  All Supported OS 


Function execution service like FunctionService.onServers() gets executed twice on a Gemfire cluster with a gateway receiver if server groups are configured.

An example of Server_Cache.xml with gateway receiver:

<gateway-receiver start-port="1530" end-port="1551" >
<cache-server port="40404"/>
<region name="exampleRegion">
<region-attributes refid="REPLICATE">


An example of gfsh start server script with group configuration:

gfsh start server --name=server1 --locators=localhost[40100] 
--server-port=40404 --cache-xml-file=Server_Cache.xml --group=test1,test2

An example of client code calling function execution service:

public class TestClient {

	public static void main(String[] args) throws Exception{
	    TestClient testClient=new TestClient();
	    ClientCache cache = new ClientCacheFactory()
	    .set("name", "TestClient")
	    .set("cache-xml-file", "xml/Client.xml")
	    .set("log-file", "xml/Client.log")
	    .set("log-level", "fine")
	    Pool pool = PoolManager.find("client");
	    }catch(InterruptedException e){}

	void executeFunction(Pool pool){
	    TestFunction function =new TestFunction();
	    Execution execution = FunctionService.onServers(pool);
	    ResultCollector collector=execution.execute("TestFunction");
	    List result=(List)collector.getResult();

	    System.out.println("******start getting result********");
	    for(String str : result){
	    System.out.println("******end getting result********");

With the above setting and code, you can see below, the log when calling the client code:

function is initialized 
******start getting result********
Function run onserver1
Function run onserver1
******end getting result********

Root Cause

This is a known bug in GatewayReceiverImpls which registers themselves with the locator in both the receiver group and any configured groups defined by the groups property.

GEM-961: Function no longer gets executed twice on gateway receivers with groups


This bug is fixed in Gemfire8.2.1.2 and later versions.

One quick workaround is to define the group in the cache.xml in cache-server section, instead of defining the group in the gemfire.properties or using the GFSH start server command:

For example:

<cache-server port="40404">

Please note that using the group definition in the cache.xml is deprecated in Gemfire7.0 and later. A side effect of this workaround is that GFSH command with the --group parameter may not work.




Powered by Zendesk