# If translog durability is set to request, then flush is required?

**URL:** <https://discuss.elastic.co/t/if-translog-durability-is-set-to-request-then-flush-is-required/358687>\
**Category:** Elasticsearch\
**Created:** [May 3, 2024, 6:56am UTC](https://discuss.elastic.co/t/if-translog-durability-is-set-to-request-then-flush-is-required/358687 "2024-05-03T06:56:55Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![Amit\_Shukla](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/amit_shukla/32/121862_2.png) [@Amit\_Shukla](https://discuss.elastic.co/u/Amit_Shukla)\
**Post date:** [May 3, 2024, 6:56am UTC](https://discuss.elastic.co/t/if-translog-durability-is-set-to-request-then-flush-is-required/358687/1 "2024-05-03T06:56:55Z")

</div>

Talking about Elasticsearch version 7.17  
This is regarding how flush API and **index.translog.durability** settings are connected to each other.  
My understanding is that if this **index.translog.durability** is set as `Request` then data for each indexing is first written to translog , then committed to disk and then response is returned to client, and then translog data is deleted.  
Is it correct or i am missing something here?

---

<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:** [May 3, 2024, 10:39am UTC](https://discuss.elastic.co/t/if-translog-durability-is-set-to-request-then-flush-is-required/358687/2 "2024-05-03T10:39:27Z")

</div>

You're correct.

You almost certainly don't need to call the flush API yourself. As per [its docs](https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-flush.html#flush-api-desc):

> Elasticsearch automatically triggers flushes as needed [...] It is also possible to trigger a flush on one or more indices using the flush API, although **it is rare for users to need to call this API directly.**

---

<div class="post-metadata">

**Author:** ![Amit\_Shukla](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/amit_shukla/32/121862_2.png) [@Amit\_Shukla](https://discuss.elastic.co/u/Amit_Shukla)\
**Post date:** [May 3, 2024, 8:40pm UTC](https://discuss.elastic.co/t/if-translog-durability-is-set-to-request-then-flush-is-required/358687/3 "2024-05-03T20:40:32Z")

</div>

@DavidTurner Some more context, curious to see if answer is still same:  
We are removing a data node from running cluster, and there we were thinking of using Flush incase some translog data is not synced to Disc.  
I guess this makes sense if **index.translog.durability** is set to **Async**  
But we have default configuration for **index.translog.durability** as **Request**. which means translog is synced before responding to request.  
Hence thought of double checking.  
Let me know your views based on above context.

---

<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:** [May 3, 2024, 8:57pm UTC](https://discuss.elastic.co/t/if-translog-durability-is-set-to-request-then-flush-is-required/358687/4 "2024-05-03T20:57:13Z")

</div>

The flush API has nothing to do with syncing the translog to disk, it's for flushing the index structures.

---

<div class="post-metadata">

**Author:** ![Amit\_Shukla](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/amit_shukla/32/121862_2.png) [@Amit\_Shukla](https://discuss.elastic.co/u/Amit_Shukla)\
**Post date:** [May 4, 2024, 3:32am UTC](https://discuss.elastic.co/t/if-translog-durability-is-set-to-request-then-flush-is-required/358687/5 "2024-05-04T03:32:35Z")

</div>

But as per [its docs](https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-flush.html#flush-api-desc) you shared, it talks about data:  
" Flushing a data stream or index is the process of making sure that any data that is currently only stored in the [transaction log](https://www.elastic.co/guide/en/elasticsearch/reference/current/index-modules-translog.html) is also permanently stored in the Lucene index."

---

<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:** [May 4, 2024, 7:16am UTC](https://discuss.elastic.co/t/if-translog-durability-is-set-to-request-then-flush-is-required/358687/6 "2024-05-04T07:16:42Z")

</div>

Exactly. The data is in the translog _before_ it's flushed.

---

<div class="post-metadata">

**Author:** ![Amit\_Shukla](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/amit_shukla/32/121862_2.png) [@Amit\_Shukla](https://discuss.elastic.co/u/Amit_Shukla)\
**Post date:** [May 4, 2024, 12:42pm UTC](https://discuss.elastic.co/t/if-translog-durability-is-set-to-request-then-flush-is-required/358687/7 "2024-05-04T12:42:38Z")

</div>

So you mean Index structure changes data is in translog and not the index data ?  
Also, what are the scenarios where users call this API?  
For Rolling Restart, Below [doc](https://www.elastic.co/guide/en/elasticsearch/reference/current/restart-cluster.html) suggests calling Flush API.

---

<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:** [May 4, 2024, 5:12pm UTC](https://discuss.elastic.co/t/if-translog-durability-is-set-to-request-then-flush-is-required/358687/8 "2024-05-04T17:12:08Z")

</div>

It might help in a rolling restart but it's not required, the data is safe on disk in the translog already.

---

<div class="post-metadata">

**Author:** ![Amit\_Shukla](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/amit_shukla/32/121862_2.png) [@Amit\_Shukla](https://discuss.elastic.co/u/Amit_Shukla)\
**Post date:** [May 4, 2024, 5:30pm UTC](https://discuss.elastic.co/t/if-translog-durability-is-set-to-request-then-flush-is-required/358687/9 "2024-05-04T17:30:49Z")

</div>

Please note that this node is going to be out of cluster. And even if data is there in translog on this node, it does not guarantee that data has been replicated to other nodes of cluster.  
Here is the sequence of events:  
Index request comes to a data node.  
Data is written in translog but not synced to segments/shards on disc.  
Translog setting was Async, so it will sync at regular interval.  
Before next interval comes, this node is down and out of cluster.  
Now data which was not synced, is lost.  
When node comes back to cluster later, cluster will consider this translog data as stale.

This is the data loss i was trying to highlight. Let me know if i missed anything.

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [May 4, 2024, 5:32pm UTC](https://discuss.elastic.co/t/if-translog-durability-is-set-to-request-then-flush-is-required/358687/10 "2024-05-04T17:32:02Z")

</div>

Do you not have replica shards configured for your indices?

---

<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:** [May 4, 2024, 6:51pm UTC](https://discuss.elastic.co/t/if-translog-durability-is-set-to-request-then-flush-is-required/358687/11 "2024-05-04T18:51:05Z")

</div>

Yeah, what Christian said. Flushing is nothing to do with replication.

---

<div class="post-metadata">

**Author:** ![Amit\_Shukla](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/amit_shukla/32/121862_2.png) [@Amit\_Shukla](https://discuss.elastic.co/u/Amit_Shukla)\
**Post date:** [May 5, 2024, 5:31am UTC](https://discuss.elastic.co/t/if-translog-durability-is-set-to-request-then-flush-is-required/358687/12 "2024-05-05T05:31:33Z")

</div>

There are 3 replicas configured for index shards. Its cluster deployed in production with TBs of data coming everyday.

---

<div class="post-metadata">

**Author:** ![Amit\_Shukla](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/amit_shukla/32/121862_2.png) [@Amit\_Shukla](https://discuss.elastic.co/u/Amit_Shukla)\
**Post date:** [May 5, 2024, 5:34am UTC](https://discuss.elastic.co/t/if-translog-durability-is-set-to-request-then-flush-is-required/358687/13 "2024-05-05T05:34:22Z")

</div>

> [@DavidTurner](#):
>
> Yeah, what Christian said. Flushing is nothing to do with replication.

I guess what you mean by above line is: Flushing is processing of pushing data to disc in Segments/Shards, and replication is step after that.  
What i am curious about is : How data consistency is taken care of in Prod clusters when one node goes down, and translog durability is configured as Async.

---

<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:** [May 5, 2024, 6:48am UTC](https://discuss.elastic.co/t/if-translog-durability-is-set-to-request-then-flush-is-required/358687/14 "2024-05-05T06:48:26Z")

</div>

> [@Amit\_Shukla](#):
>
> Flushing is processing of pushing data to disc in Segments/Shards, and replication is step after that.

No, there's no dependency between the steps. Replication generally happens first, but not always.

If you have replicas and your cluster health is green then all acknowledged write operations are successfully written to all replicas and therefore won't be lost if you lose a node.
