# Primary and replica are having different size

**URL:** <https://discuss.elastic.co/t/primary-and-replica-are-having-different-size/68113>\
**Category:** Elasticsearch\
**Created:** [December 6, 2016, 1:18am UTC](https://discuss.elastic.co/t/primary-and-replica-are-having-different-size/68113 "2016-12-06T01:18:36Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![AdaYang](https://avatars.discourse-cdn.com/v4/letter/a/97f17d/32.png) [@AdaYang](https://discuss.elastic.co/u/AdaYang)\
**Post date:** [December 6, 2016, 1:18am UTC](https://discuss.elastic.co/t/primary-and-replica-are-having-different-size/68113/1 "2016-12-06T01:18:36Z")

</div>

ES 2.4.0; using mapper-attachments plugin to index pdfs.

Suddenly after index, I see the shards size from primary and replica are different. See attached. The cluster is in green status, I didn't notice exceptions that might affect this.

The same logic I used before: I set replica as 0; after indexing, set replica to 1;

document count is the same; the store has big difference. e.g for shard 3, primary is 11.6gb, but for replica it is only 6.6gb. Is this expected?

 ![](https://us1.discourse-cdn.com/elastic/original/2X/2/23418efc1c2e8b6cb84f22bcf866d79b29184821.png)

Any idea?

---

<div class="post-metadata">

**Author:** ![danielmitterdorfer](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/danielmitterdorfer/32/110510_2.png) [@danielmitterdorfer](https://discuss.elastic.co/u/danielmitterdorfer)\
**Post date:** [December 6, 2016, 12:29pm UTC](https://discuss.elastic.co/t/primary-and-replica-are-having-different-size/68113/2 "2016-12-06T12:29:30Z")

</div>

Hi @AdaYang,

that's possible, for example the primary could have a large number of deleted documents which you wouldn't see on the replica when you change the replica count from 0 to 1 after indexing? Documents are only marked as deleted as Lucene segments are immutable. Documents are physically deleted when segments get merged.

A few more thoughts: Did you check with the number of segments with the [indices segments API](https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-segments.html)? You could also run a [force merge](https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-forcemerge.html) but note that this will cause a lot of I/O so I wouldn't do that during peak hours.

Daniel

P.S.: Please don't post screenshots but rather copy the text here.

---

<div class="post-metadata">

**Author:** ![AdaYang](https://avatars.discourse-cdn.com/v4/letter/a/97f17d/32.png) [@AdaYang](https://discuss.elastic.co/u/AdaYang)\
**Post date:** [December 6, 2016, 7:19pm UTC](https://discuss.elastic.co/t/primary-and-replica-are-having-different-size/68113/3 "2016-12-06T19:19:30Z")

</div>

Thanks @danielmitterdorfer for replying the message. I got your point. Thanks.  
After force merging the segments, now the primary and replica have the same size. Thank you very much.

Interesting, since I am just indexing document and not deleting any documents still the big difference.

---

<div class="post-metadata">

**Author:** ![danielmitterdorfer](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/danielmitterdorfer/32/110510_2.png) [@danielmitterdorfer](https://discuss.elastic.co/u/danielmitterdorfer)\
**Post date:** [December 7, 2016, 8:00am UTC](https://discuss.elastic.co/t/primary-and-replica-are-having-different-size/68113/4 "2016-12-07T08:00:54Z")

</div>

Hi @AdaYang,

> [@AdaYang](#):
>
> Interesting, since I am just indexing document and not deleting any documents still the big difference.

Ok, so there are no deletes but did you update the documents in the index maybe?

Daniel

---

<div class="post-metadata">

**Author:** ![AdaYang](https://avatars.discourse-cdn.com/v4/letter/a/97f17d/32.png) [@AdaYang](https://discuss.elastic.co/u/AdaYang)\
**Post date:** [December 7, 2016, 4:36pm UTC](https://discuss.elastic.co/t/primary-and-replica-are-having-different-size/68113/5 "2016-12-07T16:36:08Z")

</div>

thanks for following up. No... Purely bulk insert... with mapper-attachment indexing pdfs.

---

<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 4, 2017, 4:36pm UTC](https://discuss.elastic.co/t/primary-and-replica-are-having-different-size/68113/6 "2017-01-04T16:36:28Z")

</div>

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