Fix (re-)starting from a basebackup taken off a standby after a failure.
Fix (re-)starting from a basebackup taken off a standby after a failure.

When starting up from a basebackup taken off a standby extra logic has
to be applied to compute the point where the data directory is
consistent. Normal base backups use a WAL record for that purpose, but
that isn't possible on a standby.

That logic had a error check ensuring that the cluster's control file
indicates being in recovery. Unfortunately that check was too strict,
disregarding the fact that the control file could also indicate that
the cluster was shut down while in recovery.

That's possible when the a cluster starting from a basebackup is shut
down before the backup label has been removed. When everything goes
well that's a short window, but when either restore_command or
primary_conninfo isn't configured correctly the window can get much
wider. That's because inbetween reading and unlinking the label we
restore the last checkpoint from WAL which can need additional WAL.

To fix simply also allow starting when the control file indicates
"shutdown in recovery". There's nicer fixes imaginable, but they'd be
more invasive.

Backpatch to 9.2 where support for taking basebackups from standbys
was added.

greenplum-db/gpdb,lisakowen/gpdb,greenplum-db/gpdb,xinzweb/gpdb,ovr/postgres-xl,Postgres-XL/Postgres-XL,pavanvd/postgres-xl,techdragon/Postgres-XL,xinzweb/gpdb,jmcatamney/gpdb,pavanvd/postgres-xl,greenplum-db/gpdb,Postgres-XL/Postgres-XL,techdragon/Postgres-XL,ovr/postgres-xl,ovr/postgres-xl,50wu/gpdb,oberstet/postgres-xl,lisakowen/gpdb,adam8157/gpdb,50wu/gpdb,yazun/postgres-xl,Postgres-XL/Postgres-XL,jmcatamney/gpdb,ashwinstar/gpdb,greenplum-db/gpdb,jmcatamney/gpdb,adam8157/gpdb,xinzweb/gpdb,xinzweb/gpdb,jmcatamney/gpdb,ashwinstar/gpdb,adam8157/gpdb,lisakowen/gpdb,jmcatamney/gpdb,50wu/gpdb,pavanvd/postgres-xl,techdragon/Postgres-XL,greenplum-db/gpdb,adam8157/gpdb,lisakowen/gpdb,Postgres-XL/Postgres-XL,lisakowen/gpdb,oberstet/postgres-xl,xinzweb/gpdb,oberstet/postgres-xl,50wu/gpdb,ashwinstar/gpdb,xinzweb/gpdb,greenplum-db/gpdb,jmcatamney/gpdb,greenplum-db/gpdb,jmcatamney/gpdb,zeroae/postgres-xl,50wu/gpdb,ashwinstar/gpdb,lisakowen/gpdb,ashwinstar/gpdb,ovr/postgres-xl,zeroae/postgres-xl,50wu/gpdb,ashwinstar/gpdb,techdragon/Postgres-XL,yazun/postgres-xl,xinzweb/gpdb,pavanvd/postgres-xl,50wu/gpdb,adam8157/gpdb,adam8157/gpdb,zeroae/postgres-xl,zeroae/postgres-xl,oberstet/postgres-xl,adam8157/gpdb,greenplum-db/gpdb,yazun/postgres-xl,zeroae/postgres-xl,techdragon/Postgres-XL,lisakowen/gpdb,jmcatamney/gpdb,yazun/postgres-xl,pavanvd/postgres-xl,yazun/postgres-xl,lisakowen/gpdb,xinzweb/gpdb,oberstet/postgres-xl,50wu/gpdb,Postgres-XL/Postgres-XL,ashwinstar/gpdb,adam8157/gpdb,ovr/postgres-xl,ashwinstar/gpdb