Unexpected CAS exists

Hi,

We’re using 2.1.1 community edition (build-764) on a CentOS box and Java API 1.4.3.

We keep some application counter (1 -> 2 -> 3 -> …) in the Couchbase document. Single Java client with one thread is running repeatedly incrementing the counter in a loop fashion using CAS semantics:

{old_value, old_cas_id} = getCAS(key)
new_value = old_value + 1
setCAS(key, new_value, old_cas_id)

What we experience is sometimes (1 out of ~1000 calls) setCAS() unexpectedly returns an EXISTS flag as if some other client has changed the value in background. Then, if we retrieve current CAS ID it would be different from old_cas_id, and counter value would have been increased as if setCAS() has succeeded.

We’re sure that no other party is changing the key in background.

Is this an expected behaviour or a bug?

Thanks,
Kirill