# Why my expired translog files are not deleted?

**URL:** <https://discuss.elastic.co/t/why-my-expired-translog-files-are-not-deleted/205398>\
**Category:** Elasticsearch\
**Created:** [October 28, 2019, 2:52am UTC](https://discuss.elastic.co/t/why-my-expired-translog-files-are-not-deleted/205398 "2019-10-28T02:52:17Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![yc1024](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yc1024/32/42644_2.png) [@yc1024](https://discuss.elastic.co/u/yc1024)\
**Post date:** [October 28, 2019, 2:52am UTC](https://discuss.elastic.co/t/why-my-expired-translog-files-are-not-deleted/205398/1 "2019-10-28T02:52:17Z")

</div>

Hi

elasticsearch version : 6.1.3  
when call `IndexShard#afterWriteOperation` to flush , i occured (29125)[[https://github.com/elastic/elasticsearch/pull/29125](https://github.com/elastic/elasticsearch/pull/29125)]

```auto
index.translog.flush_threshold_size:5G
index.translog.retention.age:12h
index.translog.retention.size: 512M

```

when my .tlog's size \> 5G，i ocured endless flush loop  
the first .tlog file generated before 19h, total .tlog sizes have reached 6.5g

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/4/b/4bc1e156d2ef0b89c6927940ca3e8d8c8b9f2cb4.png)

In `IndexShard#afterWriteOperation``shouldPeriodicallyFlush` or `shouldRollTranslogGeneration` will call `translog.trimUnreferencedReaders()` , why my translog always growing has not been deleted by `index.translog.retention.age` or `index.translog.retention.size` policy ?

---

<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:** [October 28, 2019, 12:49pm UTC](https://discuss.elastic.co/t/why-my-expired-translog-files-are-not-deleted/205398/2 "2019-10-28T12:49:12Z")

</div>

> [@yc1024](#):
>
> why my translog always growing has not been deleted by `index.translog.retention.age` or `index.translog.retention.size` policy ?

The answer to your question is the issue to which you linked, [https://github.com/elastic/elasticsearch/pull/29125](https://github.com/elastic/elasticsearch/pull/29125), which fixes a bug in the very old version you are using. You should upgrade.

---

<div class="post-metadata">

**Author:** ![yc1024](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yc1024/32/42644_2.png) [@yc1024](https://discuss.elastic.co/u/yc1024)\
**Post date:** [October 28, 2019, 1:13pm UTC](https://discuss.elastic.co/t/why-my-expired-translog-files-are-not-deleted/205398/3 "2019-10-28T13:13:57Z")

</div>

@DavidTurner Thanks for your reply.

I see [29125](https://github.com/elastic/elasticsearch/pull/29125) fixed the wrong logic in `shouldPeriodicallyFlush()` but `rollTranslogGeneration()` or `flush()` calls `translog.trimUnreferencedReaders()`, i want to know why  
translog files has not been deleted .

```auto
    @Override
    public void rollTranslogGeneration() throws EngineException {
        try (ReleasableLock ignored = readLock.acquire()) {
            ensureOpen();
            translog.rollGeneration();
            translog.trimUnreferencedReaders();
        } catch (AlreadyClosedException e) {
            failOnTragicEvent(e);
            throw e;
        } catch (Exception e) {
            try {
                failEngine("translog trimming failed", e);
            } catch (Exception inner) {
                e.addSuppressed(inner);
            }
            throw new EngineException(shardId, "failed to roll translog", e);
        }
    }

```

_ **BTW, Is there any other way to avoid this problem besides upgrading?** _

---

<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:** [October 28, 2019, 1:56pm UTC](https://discuss.elastic.co/t/why-my-expired-translog-files-are-not-deleted/205398/4 "2019-10-28T13:56:20Z")

</div>

Sorry, 6.1 is well past the [end of its supported life](https://www.elastic.co/support/eol) and I'm not in a position to investigate further. I don't believe there is a workaround that doesn't involve upgrading.

---

<div class="post-metadata">

**Author:** ![yc1024](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yc1024/32/42644_2.png) [@yc1024](https://discuss.elastic.co/u/yc1024)\
**Post date:** [October 28, 2019, 2:00pm UTC](https://discuss.elastic.co/t/why-my-expired-translog-files-are-not-deleted/205398/6 "2019-10-28T14:00:26Z")

</div>

Thanks again

---

<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:** [November 25, 2019, 2:00pm UTC](https://discuss.elastic.co/t/why-my-expired-translog-files-are-not-deleted/205398/7 "2019-11-25T14:00:29Z")

</div>

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