From the logs, it looks like the server the client is trying to connect to is
behind compared to last zxid the client has seen:
Refusing session request for client /10.11.12.4:49237 as it has seen
zxid 0x3 our last zxid is 0x0 client must try another server
I believe the behavior we currently have is that a client can connect to an RO
server, but the server must have a view at least as recent as the server.
-Flavio
> On 12 Jul 2016, at 16:23, Benjamin Jaton <[email protected]> wrote:
>
> Hello,
>
> I'm having problems using ZK in read-only mode.
> I am using a fresh install of ZK 3.5.1-alpha where I configure the
> installation to be in a 3 nodes ensemble.
> I start this node only (QA-E8WIN11) with -Dreadonlymode.enabled=true.
>
> I see that the node QA-E8WIN11 starts the RO server properly:
> 2016-07-12 16:10:10,955 [myid:1] - INFO
> [Thread-4:ReadOnlyZooKeeperServer@73] - Read-only server started
>
> Then I make a read-only enabled client:
>
> ZooKeeper zk = new
> ZooKeeper("QA-E8WIN12:2181,QA-E8WIN13:2181,QA-E8WIN11:2181", 45000, this,
> true);
> System.out.println("Successfully established the connection with
> ZooKeeper");
>
> zk.getData("/", false, null);
> System.out.println("Done.");
>
> Note that only QA-E8WIN11 is started, the other 2 are not.
>
> When the ZK client picks QA-E8WIN11 first, it works.
> But when it picks a different node, it fails with:
>
> 16:10:13.338 org.apache.zookeeper.ZooKeeper:716 - Initiating client
> connection, connectString=QA-E8WIN12:2181,QA-E8WIN13:2181,QA-E8WIN11:2181
> sessionTimeout=45000 watcher=TestZkReadOnly@68de145
> Successfully established the connection with ZooKeeper
> 16:10:13.475 org.apache.zookeeper.ClientCnxn:1138 - Opening socket connection
> to server QA-E8WIN13/10.11.8.230:2181 <http://10.11.8.230:2181/>. Will not
> attempt to authenticate using SASL (unknown error)
> 16:10:28.469 org.apache.zookeeper.ClientCnxn:1251 - Client session timed out,
> have not heard from server in 15001ms for sessionid 0x0, closing socket
> connection and attempting reconnect
> 16:10:28.574 org.apache.zookeeper.ClientCnxn:1138 - Opening socket connection
> to server QA-E8WIN12/10.11.8.232:2181 <http://10.11.8.232:2181/>. Will not
> attempt to authenticate using SASL (unknown error)
> Exception in thread "main"
> org.apache.zookeeper.KeeperException$ConnectionLossException: KeeperErrorCode
> = ConnectionLoss for /
> at org.apache.zookeeper.KeeperException.create(KeeperException.java:99)
> at org.apache.zookeeper.KeeperException.create(KeeperException.java:51)
> at org.apache.zookeeper.ZooKeeper.getData(ZooKeeper.java:1753)
> at org.apache.zookeeper.ZooKeeper.getData(ZooKeeper.java:1782)
> at TestZkReadOnly.run(TestZkReadOnly.java:26)
> at TestZkReadOnly.main(TestZkReadOnly.java:16)
>
> I'm attaching all the logs. The server and the client are on the same machine
> QA-E8WIN11.
>
> Any help would be greatly appreciated!
>
> Thanks,
> Benjamin Jaton
> <zkclient.log><zkserver.log>