Skip to content

Commit 31324c5

Browse files
IGNITE-17679 Consistency check/repair and Read Repair documentation update (#10254)
(cherry picked from commit dd6d8ef)
1 parent 4df74d9 commit 31324c5

8 files changed

Lines changed: 219 additions & 149 deletions

File tree

docs/_data/toc.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@
182182
- title: Using Cache Queries
183183
url: key-value-api/using-cache-queries
184184
- title: Read Repair
185-
url: read-repair
185+
url: key-value-api/read-repair
186186
- title: Performing Transactions
187187
url: key-value-api/transactions
188188
- title: Working with SQL

docs/_docs/clustering/connect-client-nodes.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ There are two discovery events that are triggered on the client node when it is
7676
* `EVT_CLIENT_NODE_RECONNECTED`
7777

7878
You can listen to these events and execute custom actions in response.
79-
Refer to the link:events/listening-to-events[Listening to events] section for a code example.
79+
Please, refer to the link:events/listening-to-events[Listening to events] section for a code example.
8080

8181
== Managing Slow Client Nodes
8282

docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/BasicCacheOperations.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,10 @@ void readRepair() {
129129

130130
try (Ignite ignite = Ignition.start()) {
131131
//tag::read-repair[]
132-
IgniteCache<Object, Object> cache = ignite.cache("my_cache").withReadRepair();
132+
IgniteCache<Object, Object> cache =
133+
ignite.cache("my_cache").withReadRepair(ReadRepairStrategy.CHECK_ONLY);
133134

134-
Object value = cache.get(10);
135+
Object value = cache.get(42);
135136
//end::read-repair[]
136137
}
137138

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
// Licensed to the Apache Software Foundation (ASF) under one or more
2+
// contributor license agreements. See the NOTICE file distributed with
3+
// this work for additional information regarding copyright ownership.
4+
// The ASF licenses this file to You under the Apache License, Version 2.0
5+
// (the "License"); you may not use this file except in compliance with
6+
// the License. You may obtain a copy of the License at
7+
//
8+
// http://www.apache.org/licenses/LICENSE-2.0
9+
//
10+
// Unless required by applicable law or agreed to in writing, software
11+
// distributed under the License is distributed on an "AS IS" BASIS,
12+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
// See the License for the specific language governing permissions and
14+
// limitations under the License.
15+
= Read Repair
16+
17+
WARNING: Experimental API
18+
19+
[WARNING]
20+
====
21+
[discrete]
22+
=== Limitations
23+
A consistency check is incompatible with the following cache configurations:
24+
25+
* Caches without backups.
26+
* Near caches.
27+
* Caches that use "read-through" mode.
28+
====
29+
30+
31+
`Read Repair` refers to a technique of repairing inconsistencies between primary and backup copies of data during normal read operations. When a specific key (or keys) is read by a user operation, Ignite checks the values for the given key in all backup copies.
32+
33+
The `Read Repair` mode is designed to maintain consistency. However, read operations become {tilde}2 times more costly because backup copies are checked in addition to the primary copy. It is generally not advisable to use this mode all the time, but rather on a once-in-a-while basis.
34+
35+
To enable the `Read Repair` mode, it is necessary to obtain an instance of the cache that enables Read Repair reads as follows:
36+
37+
[source, java]
38+
----
39+
include::{javaCodeDir}/BasicCacheOperations.java[tags=read-repair, indent=0]
40+
----
41+
42+
== Strategies
43+
In case consistency violations were found, the values across the topology will be replaced by repaired values according to the chosen strategy:
44+
45+
[cols="1,4",opts="header"]
46+
|===
47+
| Strategy | Description
48+
| `LWW` a| Last write (the newest entry) wins.
49+
50+
May cause IgniteException when the fix is impossible (unable to detect the newest entry)::
51+
* Null(s) found as well as non-null values for the same key. Null (missed entry) has no version, so, it can not be compared with the versioned entry.
52+
* Entries with the same version have different values.
53+
| `PRIMARY` | Value from the primary node wins.
54+
| `RELATIVE_MAJORITY` a| The relative majority, any value found more times than any other wins.
55+
Works for an even number of copies (which is typical of Ignite) instead of an absolute majority.
56+
57+
May cause IgniteException when it is unable to detect values found more times than any other.
58+
59+
For example, when 5 copies (4 backups) are given::
60+
* and value `A` found twice, but `X`, `Y` and `Z` only once, `A` wins,
61+
* but, when `A` is found twice, as well as `B`, and `X` only once, the strategy is unable to determine the winner.
62+
63+
When 4 copies (3 backups) are given, any value found two or more times, when others are found only once, is the winner.
64+
| `REMOVE` | Inconsistent entries will be removed.
65+
| `CHECK_ONLY` | Only check will be performed.
66+
|===
67+
68+
== Events
69+
link:https://ignite.apache.org/releases/{version}/javadoc/org/apache/ignite/events/EventType.html#EVT_CONSISTENCY_VIOLATION[Сonsistency Violation Event] will be recorded for each violation in case it's configured as recordable. You may listen to this event to get notified about inconsistency issues.
70+
71+
Please, refer to the link:events/listening-to-events[Working with Events] section for the information on how to listen to events.
72+
73+
== Transactional Caches
74+
Values will be repaired::
75+
* automatically for transactions that have `TransactionConcurrency.OPTIMISTIC` concurrency mode or `TransactionIsolation.READ_COMMITTED` isolation level,
76+
77+
* at commit() phase for transactions that have `TransactionConcurrency.PESSIMISTIC` concurrency mode and isolation level other than `TransactionIsolation.READ_COMMITTED`
78+
79+
[WARNING]
80+
====
81+
[discrete]
82+
=== Limitations
83+
This proxy usage does not guarantee "all copies check" in case the value have been already cached inside the transaction.
84+
85+
In case you don't use a `READ_COMMITTED` isolation mode and already have a cached value, for example have already read the value or performed a write, you'll just get the cached value.
86+
====
87+
88+
== Atomic Caches
89+
Values will be repaired automatically.
90+
91+
[WARNING]
92+
====
93+
[discrete]
94+
=== Limitations
95+
Due to the nature of an atomic cache, false-positive results can be observed. For example, an attempt to check consistency under cache's loading may lead to a consistency violation exception.
96+
97+
By default, the implementation tries to check the given key three times. The number of attempts can be changed using `IgniteSystemProperties.IGNITE_NEAR_GET_MAX_REMAPS` property.
98+
====
99+

docs/_docs/read-repair.adoc

Lines changed: 0 additions & 56 deletions
This file was deleted.

0 commit comments

Comments
 (0)