# Replica node response to primary

**URL:** <https://discuss.elastic.co/t/replica-node-response-to-primary/40358>\
**Category:** Elasticsearch\
**Created:** [January 28, 2016, 12:43pm UTC](https://discuss.elastic.co/t/replica-node-response-to-primary/40358 "2016-01-28T12:43:34Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![skumar](https://avatars.discourse-cdn.com/v4/letter/s/e9c0ed/32.png) [@skumar](https://discuss.elastic.co/u/skumar)\
**Post date:** [January 28, 2016, 12:43pm UTC](https://discuss.elastic.co/t/replica-node-response-to-primary/40358/1 "2016-01-28T12:43:34Z")

</div>

During indexing process, indexing is first performed on primary and if successful , perform on replica which on successfully indexing response back to primary. can someone explain me what process is involved in getting successful/failed response from replica to primary.(I mean doc Id or request Id or something).  
can someone point to the code base of elasticsearch where replica shards sends back successful indexing response to primary so that success message is given back to client requested for an indexing.

Thanks

---

<div class="post-metadata">

**Author:** ![jasontedor](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jasontedor/32/66992_2.png) [@jasontedor](https://discuss.elastic.co/u/jasontedor)\
**Post date:** [January 28, 2016, 2:22pm UTC](https://discuss.elastic.co/t/replica-node-response-to-primary/40358/2 "2016-01-28T14:22:27Z")

</div>

The response from the replica to the primary is managed via the same mechanism that all other request/responses are managed in Elasticsearch: via request IDs at the transport layer. The underlying framework for these requests is [`TransportReplicationAction`](https://github.com/elastic/elasticsearch/blob/2a137b554825a5f848cfaff6311d7c298fd76fe7/core/src/main/java/org/elasticsearch/action/support/replication/TransportReplicationAction.java). Is there a more specific question that you have?

---

<div class="post-metadata">

**Author:** ![skumar](https://avatars.discourse-cdn.com/v4/letter/s/e9c0ed/32.png) [@skumar](https://discuss.elastic.co/u/skumar)\
**Post date:** [January 29, 2016, 7:25am UTC](https://discuss.elastic.co/t/replica-node-response-to-primary/40358/3 "2016-01-29T07:25:25Z")

</div>

Thanks jasontedor for your reply ,I debugged and found out request id generated corresponding to my doc which is sent to replica for its indexing.But I have a small doubt:  
Replica on successful indexing write its data to translog and sends back success response with same request Id to primary. Lets say I indexed 5 docs successfully on primary but two of them (doc 1 and doc 2) failed to write on replica for some reason, So when commit operation is performed on primary shard, how does it keep track that only doc 3 ,4 and 5 has to be committed and not doc 1 and 2 .  
can you please explain me how the above scenario is handled and point me to elasticsearch code base where primary shards is receiving response from replica.

Thanks

---

<div class="post-metadata">

**Author:** ![jasontedor](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jasontedor/32/66992_2.png) [@jasontedor](https://discuss.elastic.co/u/jasontedor)\
**Post date:** [February 15, 2016, 2:23am UTC](https://discuss.elastic.co/t/replica-node-response-to-primary/40358/4 "2016-02-15T02:23:29Z")

</div>

When that happens, a replica shard that missed a write is failed and a new copy is peer recovered from the primary. The code you're looking for starts in `TransportReplicationAction` that I mentioned previously.

---

<div class="post-metadata">

**Author:** ![skumar](https://avatars.discourse-cdn.com/v4/letter/s/e9c0ed/32.png) [@skumar](https://discuss.elastic.co/u/skumar)\
**Post date:** [February 15, 2016, 4:52am UTC](https://discuss.elastic.co/t/replica-node-response-to-primary/40358/5 "2016-02-15T04:52:13Z")

</div>

Thanks !!

---

<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:** [July 5, 2017, 11:16pm UTC](https://discuss.elastic.co/t/replica-node-response-to-primary/40358/6 "2017-07-05T23:16:30Z")

</div>


