ReactiveCouchbase / ReactiveCouchbase-core

Core library for ReactiveCouchbase
Apache License 2.0
64 stars 28 forks source link

Reconnecting after Node/Cluster bounce #39

Closed zbintliff closed 9 years ago

zbintliff commented 9 years ago

Hello,

We are switching over from the official java client to the scala reactive couchbase client. While doing some tests (bouncing nodes) we noticed that the client doesn't automatically reconnect. Given that couchbase is all about high availability I'm assuming something is wrong in our application.conf.

I can't find documentation anywhere though setting reconnect attempts and time between reconnects. Can you please provide some information?

mathieuancelin commented 9 years ago

Hi,

ReactiveCouchbase doesn't provide anything about that as I assumed the underlying official client handle that.

What is the right way to do it with the official client ?

zbintliff commented 9 years ago

Does ReactiveCouchbase extend the Java official client?

The java official client has the following parameters you can use when creating a client through a CouchbaseFactoryBuilder (assuming Java Client 1.4 since 2.0 was just released):

maxReconnectDelay :Maximum number of milliseconds to wait between reconnect attempts. MinReconnectInterval :Default minimum reconnect interval in milliseconds obsPollInterval :Wait for the specified interval before the observe operation polls the nodes. obsPollMax :The maximum number of times to poll the master and replicas to meet the desired durability requirements.

Essentially when the cluster connects it gets the mapping of all the nodes and polls them based on obsPollInterval. If it receives and error it then polls again in the MinRecconnectInterval. If it still recieves and error it increases the MinRecconnectInterval and tries again, increasing until it is at maxreconnectDelay. As soon as a node is failed over the next reconnect attempt provides a new mapping to the nodes. If the node is brought back up then the next reconnect returns healthy and the client continues to set to documents that are hashed there.

mathieuancelin commented 9 years ago

Ok, so I guess the actual work will be done with https://github.com/ReactiveCouchbase/ReactiveCouchbase-core/issues/26

zbintliff commented 9 years ago

Ok just one more thing. I see you are using couchbase 1.4.2 when the latest version is 1.4.4

In 1.4.3. there is the following bug fix: JCBC-475: The configuration management (especially with the carrier mode and during shutdown) has been reworked a little and hardened so it reacts better during node restarts and in the shutdown process of the SDK (to avoid running threads after shutdown)

So this could be the problem. There is also an issue in 1.4.2 with readFromReplica().

mathieuancelin commented 9 years ago

I'll publish a new snapshot soon with the new client version

zbintliff commented 9 years ago

Thank you!