After the initial COPY sync procedure, when adding a new node, we need to choose, for each active node, which LSN should serve as the starting point for the Ni -> new node replication.
Starting from restart point or some arbitrary LSN from the past we will rewrite already copied data. Even with the 'last update wins', it is not convenient (if not, say it could cause strange effects). So, we need to find out an LSN that corresponds to the last transaction applied before the COPY sync got the transaction snapshot.
Branch https://github.com/pgEdge/spock/tree/spoc-365 is the first (of two) steps toward doing it. Now, before starting COPY, we can save the current progress and specific positions of the final commits from remote nodes in the WAL.
There is one more step that should be done: after the copy is complete, search in the gap (last_remote_lsn_applied .. copy_snapshot_lsn) to find the committed transactions that came from other (not the donor) nodes.