Chapter 11. Consistency Guarantees

Table of Contents

Specifying Consistency Policies
Using Predefined Consistency
Using Time-Based Consistency
Using Version-Based Consistency

The KV store is built from some number of computers (called nodes) that are working together using a network. Every record in your store is first written to a master node. The master node then copies that record to other nodes in the store.

Because of the relatively slow performance of networks, there can be a possibility that, at any given moment, a write operation that was performed on the master node will not yet have been performed on some other node in the store.

Consistency, then, is the policy describing whether it is possible for a record on Node A to be different from the same record on Node B.

When there is a high likelihood that a record stored on one node is identical to the same record stored on another node, we say that we have a high consistency guarantee. Likewise, a low consistency guarantee means that there is a good possibility that a record on one node differs in some way from the same record store on another node.

You can control how high you want your consistency guarantee to be. Note that the trade-off in setting a high consistency guarantee is that your store's write performance might not be as high as if you use a low consistency guarantee.

There are several different forms of consistency guarantees that you can use. They are described in the following sections.

Specifying Consistency Policies

To specify a consistency policy, you use one of the static instances of the Consistency class, or one of its nested classes.

Once you have selected a consistency policy, you can put it to use in one of two ways. First, you can use it to define a default consistency policy using the KVStoreConfig.setConsistency() method. Use of this method means that all store operations will use that policy, unless they are overridden on an operation by operation basis.

The second way to use a consistency policy is to override the default policy using the Consistency parameter on the KVStore method that you are using to perform the store operation.

The following example shows how to set a default consistency policy for the store. We will show the per-operation usage of the Consistency class in the following sections.

package kvstore.basicExample;

import oracle.kv.Consistency;
import oracle.kv.KVStore;
import oracle.kv.KVStoreConfig;
import oracle.kv.KVStoreFactory;

...

KVStoreConfig kconfig = new KVStoreConfig("exampleStore", 
    "node1.example.org:5088, node2.example.org:4129");

kconfig.setConsistency(Consistency.NONE_REQUIRED);

KVStore kvstore = KVStoreFactory.getStore(kconfig);