forked from elastic/elasticsearch
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Docs for translog, history retention and flushing
This commit updates the docs about translog retention and flushing to reflect recent changes in how peer recoveries work. It also adds some docs to describe how history is retained for replay using soft deletes and shard history retention leases. Relates elastic#45473
- Loading branch information
1 parent
69abc64
commit c21909c
Showing
4 changed files
with
214 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
[[index-modules-history-retention]] | ||
== History retention | ||
|
||
{es} sometimes needs to replay some of the operations that were performed on a | ||
shard. For instance, if a replica is briefly offline then it may be much more | ||
efficient to replay the few operations it missed while it was offline than to | ||
rebuild it from scratch. Also, {ccr} works by performing operations on the | ||
leader cluster and then replaying those operations on the follower cluster. | ||
|
||
At the Lucene level there are really only two write operations that {es} | ||
performs on an index: a new document may be indexed, or an existing document may | ||
be deleted. Updates are implemented as an atomic operation comprising the | ||
deletion of the old document followed by the indexing of the new document. A | ||
document indexed into Lucene already contains all the information needed to | ||
replay that indexing operation, but this is not true of document deletions. To | ||
solve this, {es} uses a feature called _soft deletes_ to preserve recent | ||
deletions in the Lucene index so that they can be replayed. | ||
|
||
It is important that {es} eventually discards any soft-deleted documents to | ||
prevent long-running indices from growing without bound. {es} tries not to | ||
discard any soft-deleted documents that it expects to need in the future, | ||
because if it needs to replay a discarded operation then it has no choice but to | ||
perform a full copy of the whole index to ensure that everything remains | ||
correctly synchronized. Copying the whole index may take considerable time and | ||
resources, which is why {es} tries to avoid this where possible. | ||
|
||
{es} keeps track of the operations it expects to need to replay in future using | ||
a mechanism called _shard history retention leases_. Each process that might | ||
need operations to be replayed must first takes out a shard history retention | ||
lease. For example, this process might be a replica of a shard or it might be a | ||
shard of a follower index when using {ccr}. Each retention lease keeps track of | ||
the sequence number of the first operation that the process has not received. | ||
As the process receives operations, it increases the sequence number contained | ||
in its retention lease to indicate that it will not need to replay those | ||
operations in future. {es} can discard soft-deleted operations once they are not | ||
being held by any retention lease. | ||
|
||
If a process crashes then it cannot update its retention lease any more, which | ||
means that {es} will preserve any new operations so they can be replayed when | ||
the crashed process recovers. However, retention leases only last for a limited | ||
amount of time. If the process does not recover quickly enough then its | ||
retention lease may expire. This protects {es} from retaining history forever if | ||
a process crashes permanently, because once a retention lease has expired {es} | ||
can start to discard history again. If a process recovers after its retention | ||
lease has expired then {es} will fall back to copying the whole index since it | ||
can no longer simply replay the missing history. The expiry time of a retention | ||
lease defaults to `12h`. | ||
|
||
Soft deletes are enabled by default on indices created in recent versions, but | ||
they can be explicitly enabled or disabled at index creation time. If soft | ||
deletes are disabled then peer recoveries can still sometimes take place by | ||
copying just the missing operations from the translog | ||
<<index-modules-translog-retention,as long as those operations are retained | ||
there>>. {ccr-cap} will not function if soft deletes are disabled. | ||
|
||
[float] | ||
=== History retention settings | ||
|
||
`index.soft_deletes.enabled`:: | ||
|
||
Whether or not soft deletes are enabled on the index. Soft deletes can only be | ||
configured at index creation and only on indices created on or after 6.5.0. | ||
The default value is `true`. | ||
|
||
`index.soft_deletes.retention_lease.period`:: | ||
|
||
The maximum period to retain a shard history retention lease before it is | ||
considered expired. Shard history retention leases ensure that soft deletes | ||
are retained during merges on the Lucene index. If a soft delete is merged | ||
away before it can be replicated to a follower the following process will fail | ||
due to incomplete history on the leader. The default value is `12h`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.