Ensure recovery pause feature doesn't pause unless users can connect.
Ensure recovery pause feature doesn't pause unless users can connect.

If we're not in hot standby mode, then there's no way for users to connect
to reset the recoveryPause flag, so we shouldn't pause.  The code was aware
of this but the test to see if pausing was safe was seriously inadequate:
it wasn't paying attention to reachedConsistency, and besides what it was
testing was that we could legally enter hot standby, not that we have
done so.  Get rid of that in favor of checking LocalHotStandbyActive,
which because of the coding in CheckRecoveryConsistency is tantamount to
checking that we have told the postmaster to enter hot standby.

Also, move the recoveryPausesHere() call that reacts to asynchronous
recoveryPause requests so that it's not in the middle of application of a
WAL record.  I put it next to the recoveryStopsHere() call --- in future
those are going to need to interact significantly, so this seems like a
good waystation.

Also, don't bother trying to read another WAL record if we've already
decided not to continue recovery.  This was no big deal when the code was
written originally, but now that reading a record might entail actions like
fetching an archive file, it seems a bit silly to do it like that.

Per report from Jeff Janes and subsequent discussion.  The pause feature
needs quite a lot more work, but this gets rid of some indisputable bugs,
and seems safe enough to back-patch.

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