Chapter 10. 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 (generically referred to as nodes) that are working together using a network. All data in your store is first written to a master node. The master node then copies that data to other nodes in the store. Nodes which are not master nodes are referred to as replicas.

Because of the relatively slow performance of distributed systems, 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 row on Node A to be different from the same row on Node B.

When there is a high likelihood that a row stored on one node is identical to the same row 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 row on one node differs in some way from the same row stored 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 read 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.

Note that by default, Oracle NoSQL Database uses the lowest consistency guarantee possible.

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 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", 


KVStore kvstore = KVStoreFactory.getStore(kconfig);