Getting ArithmeticException: / by zero in 2.7.0 Java client

Hi,

I’m getting the following ArithmeticException while closing Couchbase connections. I’m using 2.7.0 Java client.

Please help to fix this issue…

INFO [25-03-2019 06:05:46] - [Thread-9] - [c.z.h.HikariDataSource:close:350] - HikariPool-1 - Shutdown initiated...
INFO [25-03-2019 06:05:46] - [Thread-9] - [c.z.h.HikariDataSource:close:352] - HikariPool-1 - Shutdown completed.
INFO [25-03-2019 06:05:46] - [cb-io-1-5] - [c.c.c.c.l.Slf4JLogger:info:120] - Disconnected from Node 10.10.10.1/ip-10-10-10-1.ec2.internal
INFO [25-03-2019 06:05:46] - [cb-io-1-3] - [c.c.c.c.l.Slf4JLogger:info:120] - Disconnected from Node 10.10.10.2/ip-10-10-10-2.ec2.internal
INFO [25-03-2019 06:05:46] - [Thread-9] - [c.c.c.c.l.Slf4JLogger:info:120] - Closed bucket test_preprod
INFO [25-03-2019 06:05:46] - [cb-io-1-3] - [c.c.c.c.l.Slf4JLogger:info:120] - Disconnected from Node 10.10.10.3/ip-10-10-10-3.ec2.internal
WARN [25-03-2019 06:05:46] - [cb-core-3-2] - [c.c.c.c.l.Slf4JLogger:warn:160] - Exception while Handling Request Events RequestEvent{request=null}
java.lang.ArithmeticException: / by zero
        at com.couchbase.client.core.node.locate.ConfigLocator.locateAndDispatch(ConfigLocator.java:89)
        at com.couchbase.client.core.RequestHandler.dispatchRequest(RequestHandler.java:259)
        at com.couchbase.client.core.RequestHandler.onEvent(RequestHandler.java:208)
        at com.couchbase.client.core.RequestHandler.onEvent(RequestHandler.java:79)
        at com.couchbase.client.deps.com.lmax.disruptor.BatchEventProcessor.run(BatchEventProcessor.java:150)
        at com.couchbase.client.deps.io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
        at java.lang.Thread.run(Thread.java:748)
INFO [25-03-2019 06:05:46] - [cb-computations-1] - [c.c.c.c.l.Slf4JLogger:info:115] - Shutdown kvIoPool: success
INFO [25-03-2019 06:05:46] - [globalEventExecutor-2-1] - [c.c.c.c.l.Slf4JLogger:info:115] - Shutdown IoPool: success
INFO [25-03-2019 06:05:46] - [cb-computations-1] - [c.c.c.c.l.Slf4JLogger:info:115] - Shutdown viewIoPool: success
INFO [25-03-2019 06:05:46] - [cb-computations-1] - [c.c.c.c.l.Slf4JLogger:info:115] - Shutdown queryIoPool: success
INFO [25-03-2019 06:05:46] - [cb-computations-1] - [c.c.c.c.l.Slf4JLogger:info:115] - Shutdown searchIoPool: success
INFO [25-03-2019 06:05:46] - [cb-computations-1] - [c.c.c.c.l.Slf4JLogger:info:115] - Shutdown Core Scheduler: success
INFO [25-03-2019 06:05:46] - [cb-computations-1] - [c.c.c.c.l.Slf4JLogger:info:115] - Shutdown Runtime Metrics Collector: success
INFO [25-03-2019 06:05:46] - [Thread-10] - [c.c.c.c.l.Slf4JLogger:info:115] - Shutdown Netty: success
INFO [25-03-2019 06:05:46] - [cb-computations-1] - [c.c.c.c.l.Slf4JLogger:info:115] - Shutdown Latency Metrics Collector: success
INFO [25-03-2019 06:05:46] - [cb-computations-1] - [c.c.c.c.l.Slf4JLogger:info:115] - Shutdown analyticsIoPool: success
INFO [25-03-2019 06:05:46] - [cb-computations-1] - [c.c.c.c.l.Slf4JLogger:info:115] - Shutdown Tracer: success
INFO [25-03-2019 06:05:46] - [cb-computations-1] - [c.c.c.c.l.Slf4JLogger:info:115] - Shutdown OrphanReporter: success
1 Like

@dony.thomas Can you please tell us the version of the server, what exactly are you doing? It would be great if you can do a cbcollect too so that it is easier to figure out what is going on

Hi! I have the same issue. It occurs each time application with couchbase-client in functional tests is shutdown.
java-client 2.7.2
core-io 1.7.2
In my functional tests I use CouchbaseMock 1.5.22

Hi Raju,

We’re using Couchbase enterprise 6.0 as server. This issue occurs when Couchbase connection is being shut down by java client. How to do a cbcollect?

@dony.thomas please look here https://docs.couchbase.com/server/6.0/cli/cbcollect-info-tool.html
Also it would be great to show your sample code

Hello,

I am also facing the same issue.
I am trying to close the bucket and facing this WARNING.
This is happening after closing bucket and before disconnecting cluster.

    2019-05-29 14:08:14.054  INFO 61578 --- [TaskScheduler-1] c.c.c.core.config.ConfigurationProvider  : Closed bucket fileProcessingDB
Closing Previous bucket: true
2019-05-29 14:08:14.059  WARN 61578 --- [    cb-core-3-2] com.couchbase.client.core.CouchbaseCore  : Exception while Handling Request Events RequestEvent{request=null}

java.lang.ArithmeticException: / by zero
	at com.couchbase.client.core.node.locate.ConfigLocator.locateAndDispatch(ConfigLocator.java:89) ~[core-io-1.7.4.jar:na]
	at com.couchbase.client.core.RequestHandler.dispatchRequest(RequestHandler.java:259) ~[core-io-1.7.4.jar:na]
	at com.couchbase.client.core.RequestHandler.onEvent(RequestHandler.java:208) ~[core-io-1.7.4.jar:na]
	at com.couchbase.client.core.RequestHandler.onEvent(RequestHandler.java:79) ~[core-io-1.7.4.jar:na]
	at com.couchbase.client.deps.com.lmax.disruptor.BatchEventProcessor.run(BatchEventProcessor.java:150) ~[core-io-1.7.4.jar:na]
	at com.couchbase.client.deps.io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) [core-io-1.7.4.jar:na]
	at java.lang.Thread.run(Thread.java:748) [na:1.8.0_181]

Disconnecting Previous cluster: true

I asked a couple of others to weigh in, but I’d recommend updating to 2.7.6 in any case as it’s entirely API compatible and some bugs have been fixed since the 2.7.0 release.

Hello @ingenthr ,

I tried to check in debug mode, and the Config Locator is getting zero nodes.

com.couchbase.client.core.node.locate.ConfigLocator.java

   Line88:     int nodeSize = nodes.size();
   Line 89:    int offset = (int) counter.getAndIncrement() % nodeSize;  

The current version I am using is this:

org.springframework.data
spring-data-couchbase
3.0.12.RELEASE

Can you please see if you could provide any other clues ?

@venugopalsmartboy thanks for raising it! We’ll look into it, but I think until we fix it you can ignore it for now. During shutdown the node list sometimes goes to 0 and the code just needs to check for that and bail out.

A potential workaround might also be to not close the bucket and then shutdown the full cluster, but rather only shutdown the cluster (which in turn will close the buckets).

@daschl Thanks! Will do that.

we’ve fixed the division by 0 exception on master and planning to release it as part of 2.7.7 which is currently undergoing testing.

1 Like

And also note for future readers, it is safe to ignore.

1 Like