# CCR exception/warning issue. RetentionLeaseNotFoundException

**URL:** https://discuss.elastic.co/t/ccr-exception-warning-issue-retentionleasenotfoundexception/257977
**Category:** Elasticsearch
**Tags:** ccr-cross-cluster-replication
**Created:** [December 8, 2020, 11:07am UTC](https://discuss.elastic.co/t/ccr-exception-warning-issue-retentionleasenotfoundexception/257977 "2020-12-08T11:07:37Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![Armen\_Petrosyan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/armen_petrosyan/32/80330_2.png) [@Armen\_Petrosyan](https://discuss.elastic.co/u/Armen_Petrosyan)
#### Post date: [December 8, 2020, 11:07am UTC](https://discuss.elastic.co/t/ccr-exception-warning-issue-retentionleasenotfoundexception/257977/1 "2020-12-08T11:07:37Z")

</div>

**Scenario**

1. Create leader cluster
2. Create index with _index.soft\_deletes.retention\_lease.period_ = 5s (\*\*\*). This period I choose only for test purposes.
3. Index document and wait 5s before next step so retention lease expire
4. Create follower cluster
5. Follow leader’s index

**Expected** :

1. Data is replicated and seen in follower cluster
2. Restore status api shows that **index was fully copied,** because the retention release expired

**Actual** :

1. Data is replicated and seen in follower cluster

2. Don’t see that index entirely copied

3. Continues warnings in log of the follower in which I see below exception:

Might be that my expectations is wrong, especially point b. But this is what I understand from [https://www.elastic.co/guide/en/elasticsearch/reference/7.x/xpack-ccr.html#ccr-leader-requirements](https://www.elastic.co/guide/en/elasticsearch/reference/7.x/xpack-ccr.html#ccr-leader-requirements)

**Quote from doc** :

(\*\*\*) The [index.soft\_deletes.retention\_lease.period](https://www.elastic.co/guide/en/elasticsearch/reference/7.x/index-modules.html#ccr-index-soft-deletes-retention-period) setting defines the maximum time to retain a shard history retention lease before it is considered expired. This setting determines how long the cluster containing your leader index can be offline, which is 12 hours by default. If a shard copy recovers after its retention lease expires, then Elasticsearch will fall back to copying the entire index, because it can no longer replay the missing history.

---

<div class="post-metadata">

### Author: ![DavidTurner](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/davidturner/32/22453_2.png) [@DavidTurner](https://discuss.elastic.co/u/DavidTurner)
#### Post date: [December 8, 2020, 3:23pm UTC](https://discuss.elastic.co/t/ccr-exception-warning-issue-retentionleasenotfoundexception/257977/2 "2020-12-08T15:23:59Z")

</div>

> [@Armen\_Petrosyan](#):
>
> - Create index with _index.soft\_deletes.retention\_lease.period_ = 5s (\*\*\*). This period I choose only for test purposes.

This is the expected behaviour with such a short retention period. Retention leases don't expire in normal operation: expiry is treated as an indication of failure.

---

<div class="post-metadata">

### Author: ![Armen\_Petrosyan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/armen_petrosyan/32/80330_2.png) [@Armen\_Petrosyan](https://discuss.elastic.co/u/Armen_Petrosyan)
#### Post date: [December 9, 2020, 6:08am UTC](https://discuss.elastic.co/t/ccr-exception-warning-issue-retentionleasenotfoundexception/257977/3 "2020-12-09T06:08:26Z")

</div>

So then

1. Ok suppose it happened. Why this exception coming continuously and making my logs bigger and bigger?
2. What if I created leader and follower, indexed documents, at the middle of replication leader failed. It recovered after lease period expired... Will I see such a warning in logs? Will I see in restore status that entire index was copied?
3. Don't sure what is the "such a short retention period" Could you please elaborate more on short/long times....

---

<div class="post-metadata">

### Author: ![DavidTurner](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/davidturner/32/22453_2.png) [@DavidTurner](https://discuss.elastic.co/u/DavidTurner)
#### Post date: [December 9, 2020, 7:32am UTC](https://discuss.elastic.co/t/ccr-exception-warning-issue-retentionleasenotfoundexception/257977/4 "2020-12-09T07:32:16Z")

</div>

> [@Armen\_Petrosyan](#):
>
> Ok suppose it happened

The exceptions are continuous because the failures are continuous, because you have set the retention lease expiry period so short. Set it back to the default and you will be fine.

> [@Armen\_Petrosyan](#):
>
> It recovered after lease period expired... Will I see such a warning in logs?

Yes, you'll see warnings if a follower returns after ≥12 hours of absence. That makes sense to me: a 12-hour outage would be pretty severe.

> [@Armen\_Petrosyan](#):
>
> Could you please elaborate more on short/long times....

The default is 12 hours. You have selected 5 seconds. 5 seconds is a lot shorter than 12 hours.

---

<div class="post-metadata">

### Author: ![Armen\_Petrosyan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/armen_petrosyan/32/80330_2.png) [@Armen\_Petrosyan](https://discuss.elastic.co/u/Armen_Petrosyan)
#### Post date: [December 9, 2020, 8:19am UTC](https://discuss.elastic.co/t/ccr-exception-warning-issue-retentionleasenotfoundexception/257977/5 "2020-12-09T08:19:50Z")

</div>

> [@DavidTurner](#):
>
> Yes, you'll see warnings if a follower returns after ≥12 hours of absence. That makes sense to me: a 12-hour outage would be pretty severe.

But I see that missing documents that are indexed \>12h ago are replicated and still these exceptions are coming.

Doc says:

The [`index.soft_deletes.retention_lease.period`](https://www.elastic.co/guide/en/elasticsearch/reference/7.x/index-modules.html#ccr-index-soft-deletes-retention-period) setting defines the maximum time to retain a shard history retention lease before it is considered expired. This setting determines how long the cluster containing your leader index can be offline, which is 12 hours by default. If a shard copy recovers after its retention lease expires, then Elasticsearch will fall back to copying the entire index, because it can no longer replay the missing history.

So I wanted to check scenario when leader came up after 12h, then "Elasticsearch will fall back to copying the entire index, because it can no longer replay the missing history." And wanted to see in recovery stats that it really happens...

---

<div class="post-metadata">

### Author: ![Armen\_Petrosyan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/armen_petrosyan/32/80330_2.png) [@Armen\_Petrosyan](https://discuss.elastic.co/u/Armen_Petrosyan)
#### Post date: [December 9, 2020, 3:00pm UTC](https://discuss.elastic.co/t/ccr-exception-warning-issue-retentionleasenotfoundexception/257977/6 "2020-12-09T15:00:36Z")

</div>

Did few more tests

**First test**

1. Create leader index (retention 1h)
2. Index document
3. Wait for 1h
4. create follower cluster and follow

**Result**  
Data is replicated  
No stats in recovery stats that index entirely copied  
Exceptions each 20-30 sec

**Second test**

1. Create leader index (retention 1h)
2. Index document
3. create follower cluster and follow
4. pause follower
5. Index document to leader
6. wait for 1 h
7. resume follower

**Result**  
Data is replicated, again don't see in recovery stats that it copies all the index from scratch. And exception thrown only once.

Totally confused.

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [January 6, 2021, 3:00pm UTC](https://discuss.elastic.co/t/ccr-exception-warning-issue-retentionleasenotfoundexception/257977/7 "2021-01-06T15:00:57Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
