2

I am using Couchbase 3.0 And I am facing this problem , that when I try to Open two buckets simultaneously It gives me the error java.util.concurrent.TimeoutException.

I have a case where I have to open two buckets simultaneously. When I comment one of the bucket opening line the code works just fine, but as soon as I want to open both the buckets It gives me an exception.

The Java SDK version is 2.1.3

 java.lang.RuntimeException: java.util.concurrent.TimeoutException
    at com.couchbase.client.java.util.Blocking.blockForSingle(Blocking.java:93) ~[java-client-2.1.3.jar:2.1.3]
    at com.couchbase.client.java.CouchbaseCluster.openBucket(CouchbaseCluster.java:108) ~[java-client-2.1.3.jar:2.1.3]
    at com.couchbase.client.java.CouchbaseCluster.openBucket(CouchbaseCluster.java:94) ~[java-client-2.1.3.jar:2.1.3]
    at com.couchbase.client.java.CouchbaseCluster.openBucket(CouchbaseCluster.java:84) ~[java-client-2.1.3.jar:2.1.3]
    at com.trakinvest.core.db.DB$CouchbaseService.bucket(DB.scala:155) ~[classes/:na]
    at com.trakinvest.core.service.SearchServiceSpec$.<init>(SearchServiceSpec.scala:26) [test-classes/:na]
    at com.trakinvest.core.service.SearchServiceSpec$.<clinit>(SearchServiceSpec.scala) [test-classes/:na]
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) [na:1.8.0_51]
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) [na:1.8.0_51]
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) [na:1.8.0_51]
    at java.lang.reflect.Constructor.newInstance(Constructor.java:422) [na:1.8.0_51]
    at org.specs2.reflect.Classes$class.createInstanceFor(Classes.scala:154) [specs2-common_2.11-2.3.12.jar:2.3.12]
    at org.specs2.reflect.Classes$.createInstanceFor(Classes.scala:207) [specs2-common_2.11-2.3.12.jar:2.3.12]
    at org.specs2.reflect.Classes$$anonfun$createInstanceOfEither$1.apply(Classes.scala:145) [specs2-common_2.11-2.3.12.jar:2.3.12]
    at org.specs2.reflect.Classes$$anonfun$createInstanceOfEither$1.apply(Classes.scala:145) [specs2-common_2.11-2.3.12.jar:2.3.12]
    at scala.Option.map(Option.scala:146) [scala-library-2.11.6.jar:na]
    at org.specs2.reflect.Classes$class.createInstanceOfEither(Classes.scala:145) [specs2-common_2.11-2.3.12.jar:2.3.12]
    at org.specs2.reflect.Classes$.createInstanceOfEither(Classes.scala:207) [specs2-common_2.11-2.3.12.jar:2.3.12]
    at org.specs2.reflect.Classes$class.org$specs2$reflect$Classes$$createInstanceForConstructor(Classes.scala:118) [specs2-common_2.11-2.3.12.jar:2.3.12]
    at org.specs2.reflect.Classes$$anonfun$4.apply(Classes.scala:98) [specs2-common_2.11-2.3.12.jar:2.3.12]
    at org.specs2.reflect.Classes$$anonfun$4.apply(Classes.scala:98) [specs2-common_2.11-2.3.12.jar:2.3.12]
    at scala.collection.immutable.List.map(List.scala:273) [scala-library-2.11.6.jar:na]
    at org.specs2.reflect.Classes$class.tryToCreateObjectEither(Classes.scala:98) [specs2-common_2.11-2.3.12.jar:2.3.12]
    at org.specs2.reflect.Classes$.tryToCreateObjectEither(Classes.scala:207) [specs2-common_2.11-2.3.12.jar:2.3.12]
    at org.specs2.reflect.Classes$class.tryToCreateObject(Classes.scala:70) [specs2-common_2.11-2.3.12.jar:2.3.12]
    at org.specs2.reflect.Classes$.tryToCreateObject(Classes.scala:207) [specs2-common_2.11-2.3.12.jar:2.3.12]
    at org.specs2.specification.SpecificationStructure$$anonfun$createSpecificationFromClassOrObject$1.apply(BaseSpecification.scala:132) [specs2-core_2.11-2.3.12.jar:2.3.12]
    at org.specs2.specification.SpecificationStructure$$anonfun$createSpecificationFromClassOrObject$1.apply(BaseSpecification.scala:132) [specs2-core_2.11-2.3.12.jar:2.3.12]
    at scala.Option.orElse(Option.scala:289) [scala-library-2.11.6.jar:na]
    at org.specs2.specification.SpecificationStructure$.createSpecificationFromClassOrObject(BaseSpecification.scala:132) [specs2-core_2.11-2.3.12.jar:2.3.12]
    at org.specs2.specification.SpecificationStructure$.createSpecificationEither(BaseSpecification.scala:117) [specs2-core_2.11-2.3.12.jar:2.3.12]
    at org.specs2.runner.SbtRunner.org$specs2$runner$SbtRunner$$specificationRun(SbtRunner.scala:73) [specs2-core_2.11-2.3.12.jar:2.3.12]
    at org.specs2.runner.SbtRunner$$anonfun$newTask$1$$anon$5.execute(SbtRunner.scala:59) [specs2-core_2.11-2.3.12.jar:2.3.12]
    at sbt.ForkMain$Run$2.call(ForkMain.java:294) [test-agent-0.13.8.jar:0.13.8]
    at sbt.ForkMain$Run$2.call(ForkMain.java:284) [test-agent-0.13.8.jar:0.13.8]
    at java.util.concurrent.FutureTask.run(FutureTask.java:266) [na:1.8.0_51]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_51]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_51]
    at java.lang.Thread.run(Thread.java:745) [na:1.8.0_51]
Caused by: java.util.concurrent.TimeoutException: null
DaveR
  • 9,540
  • 3
  • 39
  • 58
Shivansh
  • 3,454
  • 23
  • 46
  • Maybe this: https://issues.couchbase.com/browse/JVMCBC-79 . Seems that blocking calls made in the wrong place can cause this to happen. Don't have enough details on it myself though. – Mike Curry Aug 21 '15 at 08:19
  • Is there any way in which it can be resolved – Shivansh Aug 21 '15 at 09:29
  • 1
    Can you provide an extract of your code? – DaveR Aug 21 '15 at 09:46
  • val buc1: Option[Bucket] = couchbaseService.bucket(BucketName1) val buc2: Option[Bucket] = couchbaseService.bucket(BucketName2) Now If I want to use both the buckets then it gives me a timeout exception. On the buc2 and buc1 seems fine, and If I open buc2 first then buc1 gives me a timeout exception. What I mean to say Is that they do not get opened simultaneously. Please help me out. Thanks! – Shivansh Sep 02 '15 at 05:24
  • I know this is an old question, but did you try upgrading to a more recent SDK since then? (eg. 2.1.6 as of this comment) – Simon Baslé Jan 19 '16 at 17:42
  • I am using the Couchbase 4.0 now. And in this case the TimeOut exception do not arise by opening two buckets. But I do often get the TIMEOUT exception `java.lang.RuntimeException: java.util.concurrent.TimeoutException [error] at com.couchbase.client.java.util.Blocking.blockForSingle(Blocking.java:93) [error] at com.couchbase.client.java.CouchbaseBucket.upsert(CouchbaseBucket.java:268) [error] at com.couchbase.client.java.CouchbaseBucket.upsert(CouchbaseBucket.java:263)` And I can't understand how can I omit this and make sure that the data gets upserted. – Shivansh Jan 20 '16 at 06:41
  • @simon Basle: Please help me out with this. – Shivansh Jan 20 '16 at 06:51
  • how is your network quality between the client machine and the couchbase cluster? note that you should take the worst link's performance, as the client may talk to any node directly. The default timeout for a kv operation is 2500ms though (as configured on the `CouchbaseEnvironment`)... Did you change it eg. in the call to upsert like `bucket.upsert(doc, 123, TimeUnit.MILLISECONDS)`? – Simon Baslé Jan 20 '16 at 08:17
  • note the example above is an even lower timeout threshold so I don't recommend you try *that* particular setting (since apparently 2500ms is already timing out). Also, you are not mixing `bucket.async()` and `bucket` calls are you (blocking in an RxJava `Observable`) – Simon Baslé Jan 20 '16 at 08:31
  • I do not know If i am doing something wrong. Please guide me on this I am not using bucket.async() My code is something like : `Future{ bucket.upsert(document) }` If I call this code with the use of Actors and supposedly firing 5 upsert per second then In some cases it gives me that exception I am using Scala with Akka, for performing the operations. – Shivansh Jan 20 '16 at 10:19
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/101184/discussion-between-shivansh-srivastava-and-simon-basle). – Shivansh Jan 20 '16 at 11:53

1 Answers1

0

I've upgraded the version of Couchbase SDK and the problem does not occur now ! I think it might be a versioning problem ! If anyone else finds this issue try to upgrade the Couchbase SDK to resolve this error !

P.S. It was quite a long chat and hence i am giving this answer here !

Shivansh
  • 3,454
  • 23
  • 46