Re: Race condition in recovery?

Kyotaro Horiguchi <horikyota.ntt@gmail.com>

From: Kyotaro Horiguchi <horikyota.ntt@gmail.com>
To: dilipbalaut@gmail.com
Cc: robertmhaas@gmail.com, hlinnaka@iki.fi, pgsql-hackers@lists.postgresql.org
Date: 2021-05-18T06:58:08Z
Lists: pgsql-hackers
At Tue, 18 May 2021 15:52:07 +0900 (JST), Kyotaro Horiguchi <horikyota.ntt@gmail.com> wrote in 
> FWIW, you could be get a problematic base backup by the following steps.
> 
> 0. (make sure /tmp/hoge is removed)
> 1. apply the attached patch
> 2. create a primary then start
> 3. create a standby then start
> 4. place standby.signal to the primary, then restart it.
> 5. place the file /tmp/hoge.
> 6. promote the "primary".
> 7. You will see a log line like this
>    LOG:  WAIT START: CHECKPOINT_ONLINE: TLI=2
> 8. Take a base backup (without copying WAL files)

I carelessly have left the "modification" uncommented in the diff file.

@@ -6577,6 +6584,8 @@ StartupXLOG(void)
 	else
 		recoveryTargetTLI = ControlFile->checkPointCopy.ThisTimeLineID;
 
+	expectedTLEs = readTimeLineHistory(recoveryTargetTLI);
+	elog(LOG, "set expectedtles %d, %d", recoveryTargetTLI, list_length(expectedTLEs));

Disabling the lines would show the result of the ancient fix.

regards.
-- 
Kyotaro Horiguchi
NTT Open Source Software Center



Commits

  1. Further refinement of stuck_on_old_timeline recovery test

  2. Adjust new test case to set wal_keep_segments.

  3. Adjust new test case to set wal_keep_size.

  4. Fix corner case failure of new standby to follow new primary.

  5. Back-port a few PostgresNode.pm methods.

  6. Allow PostgresNode.pm's backup method to accept backup_options.

  7. Add end-to-end testing of pg_basebackup's tar-format output.

  8. Allow PostgresNode.pm tests to wait for catchup

  9. Delay reading timeline history file until it's fetched from master.