Riak. MultiDelete of RiakClient don't throw Exception

73 views Asked by At

I use MultiDelete for acceleration of remove operation. When need remove batch of objects from Riak:

public void deleteBatch(Collection<String> keys) throws ExecutionException,     InterruptedException {
    Namespace bucket = new Namespace(BUCKET_TYPE_DEFAULT, riakBucketName);

    MultiDelete.Builder builder = new MultiDelete.Builder();

    for (String uuid : keys) {
        if (isNotBlank(uuid)) {
            builder.addLocation(new Location(bucket, uuid));
        }
    }
    try {
        MultiDelete cmd = builder.build();
        riakClient.execute(cmd);
    } catch (Exception e) {
        log.error("Error delete", e);
        throw e;
    }
}

But if something goes wrong, for example, a Network problem (ConnectException: Connection refused), then I don't catch Exception in the block "catch". I can see errors only in the application log. This is a problem for me because I don't know if these objects were removed from Riak or not.

1

There are 1 answers

0
Peter Clark On

I don't have a simple solution to this based on your question, but what you can do is look through the keys and see which ones are left.

Key listing can be achieved via https://www.tiot.jp/riak-docs/riak/kv/2.2.6/developing/api/protocol-buffers/list-keys/ for pbc or https://www.tiot.jp/riak-docs/riak/kv/2.2.6/developing/api/http/list-keys/ for the http interface.

Prior to Riak KV 2.9.x key listing would cause a lot of load on the cluster and was not recommended for usage in production (see the note in the docs link provided). For Riak KV 2.9.x and above, it is now safe to do due to automatic throttling in the background.