Java SDK Counter Bug

I am using counters as an AI id in my application.
I am using couchbase server 4.0 CE.

Using java sdk version > 2.2.0 I get ‘DocumentDoesNotExist’ exceptions when creating new counters.

I am explicitly setting an initial value, which should not throw this exception according to this documentation: http://developer.couchbase.com/documentation/server/4.0/sdks/java-2.2/documents-atomic.html

See a sample code snippet:

String id = getCounterId();
JsonLongDocument value = bucket.counter(id, 1L, 1L); // throws DDNE exception

dzagieboylo,
it’s a https://issues.couchbase.com/browse/MB-17231
See my post: Couchbase 4.0 community huge delay returning result with “full ejection” set

public workaroud: do not use “full eviction” for bucket
IMHO, this makes 4.0.0 CE completely unusable for configurations with 512…1G RAM

Ahh I see, thanks for the information.
I don’t think that workaround will be possible for us, as we are storing a large history of data in our bucket; the recent data in RAM is most accessed but we need to have all of it accessible. Therefore the RAM required to store all keys is extremely high.

While not as high performing, do you think it would be reasonable for me to implement the AI id feature using CB locks? I’d prefer not to do this but if the 4.1 release is not soon forthcoming on CE I may need to implement some workaround.

I just don’t know what “AI id feature” is :slight_smile:

As i suppose 4.1.1-EE (released recently) has broken indexer; see my post 4.1.0-EE vs 4.1.1-EE: indexer too slow
So, 4.1.1-EE really fixes https://issues.couchbase.com/browse/MB-17231, but introduces (probably) broken indexer. And, of course, there is no info about (possible ?) 4.1.1-CE release.

I’m referring to the traditional SQL ‘Auto Increment Id’ feature :slight_smile:

Ah, ok :slight_smile: I thougt “AI = Artifical intellegence” :slight_smile:
I don’t think you should “reinvent the wheel” by using locks.

  1. Google (or search this forum) for something like “couchbase sql auto increment implementation”, obviously, you are not the first one in the world with this problem.
  2. “Think different”: does your application really needs “sequential ids” ? Try timestamps as IDs, data-chunk-hashes as IDs, user-defined ids etc. And google “different ideas” too.

Anyway, i think further discussion is out of bounds for current topic.

I got this error too.
how to resolve this error?
@grep what does “full eviction” mean?

bucket
.async()
.counter(“counter”, 1)
.flatMap(new Func1<JsonLongDocument , Observable<?>>() { public Observable<?> call(JsonLongDocument counterRes) {
String id = “doc” + counterRes.content();
System.out.println("id = " + id);

            return bucket.async().insert(RawJsonDocument.create(id, "dddd"));
        }
    })
    .toBlocking()
    .single();

com.couchbase.client.java.error.DocumentDoesNotExistException
at com.couchbase.client.java.CouchbaseAsyncBucket$31.call(CouchbaseAsyncBucket.java:919)
at com.couchbase.client.java.CouchbaseAsyncBucket$31.call(CouchbaseAsyncBucket.java:904)
at rx.internal.operators.OnSubscribeMap$MapSubscriber.onNext(OnSubscribeMap.java:69)
at rx.observers.Subscribers$5.onNext(Subscribers.java:235)
at rx.internal.operators.OnSubscribeDoOnEach$DoOnEachSubscriber.onNext(OnSubscribeDoOnEach.java:101)
at rx.internal.producers.SingleProducer.request(SingleProducer.java:65)
at rx.Subscriber.setProducer(Subscriber.java:211)
at rx.internal.operators.OnSubscribeMap$MapSubscriber.setProducer(OnSubscribeMap.java:102)
at rx.internal.operators.OnSubscribeMap$MapSubscriber.setProducer(OnSubscribeMap.java:102)
at rx.Subscriber.setProducer(Subscriber.java:205)
at rx.Subscriber.setProducer(Subscriber.java:205)
at rx.subjects.AsyncSubject.onCompleted(AsyncSubject.java:103)
at com.couchbase.client.core.endpoint.AbstractGenericHandler.completeResponse(AbstractGenericHandler.java:384)
at com.couchbase.client.core.endpoint.AbstractGenericHandler.access$000(AbstractGenericHandler.java:69)
at com.couchbase.client.core.endpoint.AbstractGenericHandler$1.call(AbstractGenericHandler.java:402)
at rx.internal.schedulers.ScheduledAction.run(ScheduledAction.java:55)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: rx.exceptions.OnErrorThrowable$OnNextValue: OnError while emitting onNext value: com.couchbase.client.core.message.kv.CounterResponse.class
at rx.exceptions.OnErrorThrowable.addValueAsLastCause(OnErrorThrowable.java:118)
at rx.internal.operators.OnSubscribeMap$MapSubscriber.onNext(OnSubscribeMap.java:73)
… 20 more

Hello guys,
Any body has the solution for this exception?
I also have this exception when I use couchbase client to increase/decrease a counter.

bucket.counter("sequenceNoGenerator", 1L, 1L, 1000000)