Its complicated. Newer versions of Elasticsearch can cancel replication in progress and I believe in 2.x its possible for it to do this abort but I could be wrong. I don't know that code super well.
When N2 comes back Elasticsearch has to make sure that R2 is the same as R1. It can do this in two ways:
the files are the same
synced flush
If it doesn't see R2 as the same as R1 then it'll take into account how much of it is the same when determining which shard is "further along".
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.