Dear Alexander,
> From my old records, 009_twophase.pl failed exactly due to background (
> namely, bgwriter's) activity.
Okay, so I think there are two reasons why the test could fail.
1) old primary shut down before all changes are replicated. This can avoid by
adding wait_for_replay_catchup() before the tearing down.
2) bgwriter on old primary generated the RUNNING_XACTS record and the node shut
dwon before sending it.
.. and you mentioned for the case 2), right? I recalled that an injection point
"skip-log-running-xacts" can be used to supress generating the WAL record, see
035_standby_logical_decoding.pl. My idea is to attach the injeciton point before
the switchover and avoid adding the record.
Attached patch implements the idea.
How do you feel?
Best regards,
Hayato Kuroda
FUJITSU LIMITED