Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Observed "Failed to close connection for host "errors when one of the server is down in a cluster #263

Open
ghost opened this issue Apr 12, 2019 · 5 comments

Comments

@ghost
Copy link

ghost commented Apr 12, 2019

hi
I build dynomite cluster and if one of the node is get down I observed below mentioned errors in my log file . please give solution

ERROR Consumer_metric_data-cassandra_metric_worker_0 12/Apr/2019 10:25:27 com.netflix.dyno.connectionpool.impl.HostConnectionPoolImpl - Failed to close connection for host: Host [hostname=RedisMaster, ipAddress=192.168.56.221, port=8102, rack: dc1a, datacenter: dc1, status: Up, hashtag=null, password=null] java.net.SocketException: Broken pipe (Write failed)
ERROR Consumer_metric_data-cassandra_metric_worker_0 12/Apr/2019 10:25:27 com.netflix.dyno.connectionpool.impl.HostConnectionPoolImpl - Failed to close connection for host: Host [hostname=RedisMaster, ipAddress=192.168.56.221, port=8102, rack: dc1a, datacenter: dc1, status: Up, hashtag=null, password=null] java.net.SocketException: Broken pipe (Write failed)
ERROR Consumer_dist_jobs-dist_jobs_worker_0 12/Apr/2019 10:30:00 com.netflix.dyno.connectionpool.impl.HostConnectionPoolImpl - Failed to close connection for host: Host [hostname=RedisMaster, ipAddress=192.168.56.221, port=8102, rack: dc1a, datacenter: dc1, status: Up, hashtag=null, password=null] java.net.SocketException: Broken pipe (Write failed)
ERROR Consumer_dist_jobs-dist_jobs_worker-23-thread-1 12/Apr/2019 10:30:00 com.netflix.dyno.connectionpool.impl.HostConnectionPoolImpl - Failed to close connection for host: Host [hostname=RedisMaster, ipAddress=192.168.56.221, port=8102, rack: dc1a, datacenter: dc1, status: Up, hashtag=null, password=null] Unexpected end of stream.
ERROR Consumer_dist_jobs-dist_jobs_worker_0 12/Apr/2019 10:30:00 com.netflix.dyno.connectionpool.impl.HostConnectionPoolImpl - Failed to close connection for host: Host [hostname=RedisMaster, ipAddress=192.168.56.221, port=8102, rack: dc1a, datacenter: dc1, status: Up, hashtag=null, password=null] java.net.SocketException: Broken pipe (Write failed)
ERROR Consumer_metric_data-cassandra_metric_worker_0 12/Apr/2019 10:30:28 com.netflix.dyno.connectionpool.impl.HostConnectionPoolImpl - Failed to close connection for host: Host [hostname=RedisMaster, ipAddress=192.168.56.221, port=8102, rack: dc1a, datacenter: dc1, status: Up, hashtag=null, password=null] java.net.SocketException: Broken pipe (Write failed)
ERROR Consumer_metric_data-cassandra_metric_worker_0 12/Apr/2019 10:30:28 com.netflix.dyno.connectionpool.impl.HostConnectionPoolImpl - Failed to close connection for host: Host [hostname=RedisMaster, ipAddress=192.168.56.221, port=8102, rack: dc1a, datacenter: dc1, status: Up, hashtag=null, password=null] java.net.SocketException: Broken pipe (Write failed)
ERROR Consumer_metric_data-cassandra_metric_worker_0 12/Apr/2019 10:35:29 com.netflix.dyno.connectionpool.impl.HostConnectionPoolImpl - Failed to close connection for host: Host [hostname=RedisMaster, ipAddress=192.168.56.221, port=8102, rack: dc1a, datacenter: dc1, status: Up, hashtag=null, password=null] Unexpected end of stream.
ERROR Consumer_metric_data-cassandra_metric_worker_0 12/Apr/2019 10:35:29 com.netflix.dyno.connectionpool.impl.HostConnectionPoolImpl - Failed to close connection for host: Host [hostname=RedisMaster, ipAddress=192.168.56.221, port=8102, rack: dc1a, datacenter: dc1, status: Up, hashtag=null, password=null] java.net.SocketException: Broken pipe (Write failed)
ERROR Consumer_metric_data-cassandra_metric_worker_0 12/Apr/2019 10:40:30 com.netflix.dyno.connectionpool.impl.health.ConnectionPoolHealthTracker - FAIL: Attempting to reconnect pool due to exceptions =>FatalConnectionException: [host=Host [hostname=RedisMaster, ipAddress=192.168.56.221, port=8102, rack: dc1a, datacenter: dc1, status: Up, hashtag=null, password=null], latency=0(0), attempts=1]redis.clients.jedis.exceptions.JedisConnectionException: Unexpected end of stream.
ERROR Consumer_metric_data-cassandra_metric_worker_0 12/Apr/2019 10:40:30 com.netflix.dyno.connectionpool.impl.health.ConnectionPoolHealthTracker - Enqueueing host cp for recycling due to too many errors: HostConnectionPool: [Host: Host [hostname=RedisMaster, ipAddress=192.168.56.221, port=8102, rack: dc1a, datacenter: dc1, status: Up, hashtag=null, password=null], Pool active: true]

@ghost ghost changed the title Observed errors when one of the server is down in a cluster Observed "Failed to close connection for host "errors when one of the server is down in a cluster Apr 12, 2019
@chrisbendel
Copy link

chrisbendel commented Apr 12, 2019

More information in #166

To prevent things from blowing up (not sure if this is the best way), I added the allowFallback param to the retrypolicyfactory on my connectionpoolconfig. If there is another host/node in the pool, it will fallback to a different one as opposed to exploding.

ConnectionPoolConfigurationImpl cp = new ConnectionPoolConfigurationImpl("bbs") .setFailOnStartupIfNoHosts(true) .setRetryPolicyFactory(new RetryNTimes.RetryFactory(2, true)) .setLocalRack(localRack) .withTokenSupplier(tokenMapSupplier);

Specifically refer to this comment #166 (comment) and the following one about the LOCAL_RACK env variable

PS. Please provide some code of your implementation in the future. It will help others understand your issue better and give them an idea of what might specifically be wrong with your implementation

@ghost
Copy link
Author

ghost commented Apr 15, 2019

@chrisbendel I also using same properties
new DynoJedisClient.Builder()
.withApplicationName(clientName)
.withDynomiteClusterName(clusterName)
.withCPConfig(new ConnectionPoolConfiguration(clientName)
.withTokenSupplier(TokenMapSupplierHelper.toTokenMapSupplier(nodes))
.setMaxConnsPerHost(maxConnections)
.setConnectTimeout(maxTimeOut)
.setRetryPolicyFactory(new RetryNTimes.RetryFactory(retryCount,true))
.setMaxTimeoutWhenExhausted(maxTimeOutExhausted)
.setLocalRack(localRack)
.setLocalDataCenter(localDc)
.setMaxFailoverCount(maxFailOverCount)
)
.withHostSupplier(TokenMapSupplierHelper.toHostSupplier(nodes))
.build();

@ghost
Copy link
Author

ghost commented Apr 15, 2019

@chrisbendel but I am getting issue. when one of the node in cluster is stopped

@chrisbendel
Copy link

I observed a similar issue when setting the localDataCenter on the connection pool.

Can you please provide the code you have for your hostsupplier and tokenmapsupplier?

In the future, you can also use triple backticks around your code to format it properly.

@ramuvistara
Copy link

ramuvistara commented May 16, 2019

@chrisbendel sorry for the late response

public static TokenMapSupplier toTokenMapSupplier(List nodes){
StringBuilder jsonSB = new StringBuilder("[");
int count = 0;
for(DynomiteNodeInfo node: nodes){
jsonSB.append(" {"token":""+ node.getTokens()
+ "","hostname":"" + node.getHostname()
+ "","ip":"" + node.getIpaddress()
+ "","zone":"" + node.getRack()
+ "","rack":"" + node.getRack()
+ "","dc":"" + node.getDc()
+ ""} ");
count++;
if (count < nodes.size())
jsonSB.append(" , ");
}
jsonSB.append(" ]"");
final String json = jsonSB.toString();
TokenMapSupplier testTokenMapSupplier = new AbstractTokenMapSupplier(8102) {
@OverRide
public String getTopologyJsonPayload(String hostname) {
return json;
}
@OverRide
public String getTopologyJsonPayload(java.util.Set activeHosts) {
return json;
}
};
return testTokenMapSupplier;
}

public static HostSupplier toHostSupplier(List<DynomiteNodeInfo> nodes){
	final Collection<Host> hosts = new ArrayList<Host>();
	
	for(DynomiteNodeInfo node: nodes){
		hosts.add(buildHost(node));
	}
	
	final HostSupplier customHostSupplier = new HostSupplier() {
	 @Override
	   public List<Host> getHosts() {
		   return (List<Host>) hosts;
	   }
	};
	return customHostSupplier;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants