fix livelock happens when merging node restarted during the process.

The test is like 90 lines long. Must be a way to split it up