Avoid consuming an XID during vac_truncate_clog().
Avoid consuming an XID during vac_truncate_clog().

vac_truncate_clog() uses its own transaction ID as the comparison point in
a sanity check that no database's datfrozenxid has already wrapped around
"into the future".  That was probably fine when written, but in a lazy
vacuum we won't have assigned an XID, so calling GetCurrentTransactionId()
causes an XID to be assigned when otherwise one would not be.  Most of the
time that's not a big problem ... but if we are hard up against the
wraparound limit, consuming XIDs during antiwraparound vacuums is a very
bad thing.

Instead, use ReadNewTransactionId(), which not only avoids this problem
but is in itself a better comparison point to test whether wraparound
has already occurred.

Report and patch by Alexander Korotkov.  Back-patch to all versions.

Report: <8aa020343120c23d7eee6346aababd5933364417@mail.gmail.com>

adam8157/gpdb,ashwinstar/gpdb,ashwinstar/gpdb,greenplum-db/gpdb,greenplum-db/gpdb,xinzweb/gpdb,50wu/gpdb,lisakowen/gpdb,greenplum-db/gpdb,adam8157/gpdb,xinzweb/gpdb,jmcatamney/gpdb,lisakowen/gpdb,adam8157/gpdb,ashwinstar/gpdb,adam8157/gpdb,xinzweb/gpdb,xinzweb/gpdb,jmcatamney/gpdb,adam8157/gpdb,ashwinstar/gpdb,jmcatamney/gpdb,jmcatamney/gpdb,adam8157/gpdb,greenplum-db/gpdb,adam8157/gpdb,jmcatamney/gpdb,50wu/gpdb,jmcatamney/gpdb,xinzweb/gpdb,greenplum-db/gpdb,jmcatamney/gpdb,lisakowen/gpdb,50wu/gpdb,jmcatamney/gpdb,ashwinstar/gpdb,xinzweb/gpdb,lisakowen/gpdb,lisakowen/gpdb,50wu/gpdb,adam8157/gpdb,ashwinstar/gpdb,lisakowen/gpdb,lisakowen/gpdb,50wu/gpdb,ashwinstar/gpdb,greenplum-db/gpdb,ashwinstar/gpdb,greenplum-db/gpdb,50wu/gpdb,greenplum-db/gpdb,lisakowen/gpdb,50wu/gpdb,xinzweb/gpdb,xinzweb/gpdb,50wu/gpdb