Thanks for the response John.
What if network re-orders the message, it could still be possible, right ?
Considering the same scenario explained above:
Term X - 10
1. leader sends AppendEntry { lsn: Y, term: X - 10 } to the follower. ------- (1*)
2. follower doesn't receive the AppendEntry yet
Term X
3. Leader at term X-10 becomes leader again in term X
4. Leader tries to figure out the matchIndex of that follower
5. Leader sends AppendEntry { lsn: Y, term: X } to the follower --------- (2*)
6. Follower receives request (2*) and sends a successful response back, AppendResult { success: true, lsn: Y, term: X } ---- (3*)
7. Follower now receives request (1*) and sends a reject response back due to stale term, AppendResult { success: false, lsn: Y, term: X } --- (4*)
Now leader receives (3*) and (4*), also in that order. Processing (3*), would set the matchIndex[follower] to Y. Processing (4*) would set the nextIndex[follower] to Y-1.
By now, the nextIndex[follower] < matchIndex[follower]
Do let me know, if there are any inaccuracies in the scenario explained