aerospike / aerospike-client-java

Aerospike Java Client Library
Other
236 stars 212 forks source link

Wrong condition for aeropsike client connectivity #223

Closed anuragagarwal561994 closed 1 year ago

anuragagarwal561994 commented 2 years ago

In the line:

https://github.com/aerospike/aerospike-client-java/blob/1a84574f7fd0063959452bd0cf490a00b44063e9/client/src/com/aerospike/client/cluster/Cluster.java#L523

nodes.length == 1 is being checked.

As far as I understand, if there are 2 hosts in the config and 1 is unreachable, then this would lead to an error in initiating the client. However since there is 1 node available, ideally we can bring the client up

BrianNichols commented 2 years ago

That code handles a common external client scenario where the seed node (host name) resolves, but all peer nodes (AWS internal IP addresses) are not reachable. This causes all sorts of transaction errors because the partition map will never be fully populated. We decided it was best to force users to fix their IP address misconfiguration before running their application.

You can still override the behavior by setting ClientPolicy.failIfNotConnected = false.

anuragagarwal561994 commented 2 years ago

So for some legacy reason we have 2 IPs in our system 1 resolve to correct host and 1 doesn't. Ideally in this case the client should be created but it throws an error.

failIfNotConnected = false will also not fail I guess if none of the IPs resolve

BrianNichols commented 2 years ago

You can prevent the error by setting ClientPolicy.failIfNotConnected = false.

anuragagarwal561994 commented 2 years ago

Thanks

chenjinfeng0505 commented 1 year ago

@BrianNichols Hi,I had the same problem. I has seven nodes but only first node is unavailable.
Now data can be read from nodes and failed to write in all nodes.

I think that the working nodes should remove useless nodes and data can be written and read normally.

Do you have any suggestions to ensure that other nodes work normally? Thanks

BrianNichols commented 1 year ago

You can provide multiple seed hosts to AerospikeClient. If the first seed fails, the other seeds will be tried.

Also, the client lets the servers nodes decide which nodes belong in the cluster or not.