Nullpointer when locating key

#1

Hi All,

Sometimes we are getting this nullpointer errors. Are there any suggestions about this error.

Thanks

07:15:45.861 [cb-core-3-2] WARN c.c.client.core.CouchbaseCore - Exception while Handling Request Events RequestEvent{request=null}, {}
java.lang.NullPointerException: null
at com.couchbase.client.core.node.locate.KeyValueLocator.locateForCouchbaseBucket(KeyValueLocator.java:97) ~[com.couchbase.client.core-io-1.1.3.jar:1.1.3]
at com.couchbase.client.core.node.locate.KeyValueLocator.locate(KeyValueLocator.java:75) ~[com.couchbase.client.core-io-1.1.3.jar:1.1.3]
at com.couchbase.client.core.RequestHandler.onEvent(RequestHandler.java:188) ~[com.couchbase.client.core-io-1.1.3.jar:1.1.3]
at com.couchbase.client.core.RequestHandler.onEvent(RequestHandler.java:73) ~[com.couchbase.client.core-io-1.1.3.jar:1.1.3]
at com.couchbase.client.deps.com.lmax.disruptor.BatchEventProcessor.run(BatchEventProcessor.java:128) ~[com.couchbase.client.core-io-1.1.3.jar:1.1.3]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_25]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_25]
at com.couchbase.client.deps.io.netty.util.concurrent.DefaultThreadFactory$DefaultRunnableDecorator.run(DefaultThreadFactory.java:137) [com.couchbase.client.core-io-1.1.3.jar:1.1.3]
at java.lang.Thread.run(Thread.java:745) [na:1.8.0_25]
07:16:15.761 [cb-core-3-2] WARN c.c.client.core.CouchbaseCore - Exception while Handling Request Events RequestEvent{request=null}, {}
java.lang.NullPointerException: null
07:22:55.901 [cb-core-3-2] WARN c.c.client.core.CouchbaseCore - Exception while Handling Request Events RequestEvent{request=null}, {}
java.lang.NullPointerException: null
07:23:25.801 [cb-core-3-2] WARN c.c.client.core.CouchbaseCore - Exception while Handling Request Events RequestEvent{request=null}, {}
java.lang.NullPointerException: null
07:26:02.821 [cb-core-3-2] WARN c.c.client.core.CouchbaseCore - Exception while Handling Request Events RequestEvent{request=null}, {}
java.lang.NullPointerException: null
07:30:05.941 [cb-core-3-2] WARN c.c.client.core.CouchbaseCore - Exception while Handling Request Events RequestEvent{request=null}, {}
java.lang.NullPointerException: null
07:30:35.841 [cb-core-3-2] WARN c.c.client.core.CouchbaseCore - Exception while Handling Request Events RequestEvent{request=null}, {}
java.lang.NullPointerException: null

#2

@yadiguzel I just checked the code, and it looks like this is the code where we turn the key into a byte array.

Can you describe the workload you’re running? We need to track down a potential null key somewhere in your code. Maybe can you also share the code?

#3

@daschl here is my code in getWithCas method i can check whether is null or not. But this id is session id it can’t be null.

Our workload is not huge about 4000 req/s on each bucket in normal conditions. I could be up to 8K req/s.

object CouchbaseConnectionService extends Configuration with Logging {

val environment : CouchbaseEnvironment = DefaultCouchbaseEnvironment.builder().build()
val cluster = CouchbaseCluster.create(config.getConfig(“couchbase”).getStringList(“servers”))
val sessionBucket = cluster.openBucket(“Sessions”)
val tracksBucket = cluster.openBucket(“Tracks”)
val usersBucket = cluster.openBucket(“Users”)
val logsBucket = cluster.openBucket(“Logs”)
val empty = Some((JsonObject.empty(), 0))

def resolveBucket(name: String): Bucket = {
name match {
case “Sessions” => sessionBucket
case “Tracks” => tracksBucket
case “Users” => usersBucket
case “Logs” => logsBucket
case _ => sessionBucket
}
}

def query(q: ViewQuery, from: String): Future[ViewResult] = {
Future {
resolveBucket(from).query(q)
}
}

def getWithCas(from: String, id: String): Option[(JsonObject, Long)] = {
try {
val result = resolveBucket(from).get(id, 10, TimeUnit.SECONDS)
if (result != null) {
//log.info(s"${id} loaded from ${from} with cas ${result.cas}")
Some(result.content(), result.cas)
} else {
Some(JsonObject.empty(), 0L)
}
} catch {
case e: Throwable => None
}
}

#4

@yadiguzel can you reproduce this in a development environment? It would be interesting to see what the request that it is trying to locate looks like - that would help a lot!