Java Client update vs store
cosminaru at gmail.com
Tue Feb 3 17:39:12 EST 2015
I have an edge case where consistency is favoured over availability so I’m using a "consistent": true bucket type for a very specific operation.
I worked in testing my setup so ended up faking an entire failure by deliberately using an incorrect vClock.
Using StoreValue, the (second) write fails as expected
FetchValue fetchOp = new FetchValue.Builder(location(id)).build();
VClock vClock = client.execute(fetchOp).getVectorClock();
//fiddle with vClock or allow the first write to finish before the next step
StoreValue storeOp = new StoreValue.Builder(value)
StoreValue.Response response = client.execute(storeOp);
Caused by: com.basho.riak.client.core.netty.RiakResponseException: failed
I managed to override the UpdateValue class to simulate a similar failure scenario (so I don’t have to do the fetch + store myself). I was expecting a similar result, however, after some analysis I realised that an exception is being swallowed somewhere.
I believe the trouble might be around this area: https://github.com/basho/riak-java-client/blob/develop/src/main/java/com/basho/riak/client/api/commands/kv/UpdateValue.java#L581
The exception is not allowed to bubble up to the client code. Additionally, another net effect of this seems to be that a null response is returned here
UpdateValue.Response res = client.execute(updateOp);
So a call to res.wasUpdated() will produce a NPE!
The way I see it, this code needs to either
1) return not-null res and res.wasUpdated() as false
2) allow the exception to bubble up
Please let me know your thoughts
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the riak-users