Found this bug with randomized testing. The following sequence causes a problem:
- JN writing segment starting at txid 1, and successfully wrote txid 1, but no more
- JN becomes partitioned from NN, and a new NN takes over
- new NN is also partitioned for the "prepareRecovery" phase of recovery, but properly connects for the "acceptRecovery" call
- acceptRecovery copies over a longer log segment (eg txns 1-3) from a good logger
- new NN calls finalizeLogSegment(), but gets the following error: JournalOutOfSyncException: Trying to finalize in-progress log segment 1 to end at txid 3 but only written up to txid 1
This is because the "syncLog" call (which copies the new segment) isn't properly aborting the old segment before replacing it.