Java client Delete with CAS Not working as expected


#1

I tried the following sequence on OSX, running Couchbase Enterprise server version 2.1.1-764-rel and Java client 1.1.8 (and reverified on 1.1.9).

java -version gives me:

java version "1.7.0_13"
Java™ SE Runtime Environment (build 1.7.0_13-b20)
Java HotSpot™ 64-Bit Server VM (build 23.7-b01, mixed mode)

Run the following program:

public class Main { public static void main(String[] args) throws Exception { CouchbaseClient client = new CouchbaseClient( Arrays.asList(new URI("http://localhost:8091/pools")), "bucket", "");
    boolean setSuccess = client.set("foo", "dummy").get();

    CASValue<Object> cas = client.getAndLock("foo", 30);
    boolean deleteSuccess = client.delete("foo", cas.getCas()).get();

    Object value = client.get("foo");

    client.shutdown();
}

}

I am surprised by the values of the variables deleteSuccess and value. I see “false” and “dummy” but expected “true” and null.

Is this a bug in the Java client (or Couchbase server?) or am I doing something wrong?


#2

Hello,

Your code is correct, but you are currently hitting a server but that will be fixed in Couchbase 2.2.

You can find the information about this bug here:
http://www.couchbase.com/issues/browse/MB-8992

For now you will have to unlock the key before doing the delete.

Sorry for this.

Regards
Tug
@tgrall


#3

Thank you. At least I’m not crazy. Although it is disappointing that this is a server bug that will take a while to release a fix for.