Fix logic in lazy vacuum to decide if it's worth trying to truncate the heap. If the table was smaller than REL_TRUNCATE_FRACTION (= 16) pages, we always tried to acquire AccessExclusiveLock on it even if there was no empty pages at the end.
Fix logic in lazy vacuum to decide if it's worth trying to truncate the heap.
If the table was smaller than REL_TRUNCATE_FRACTION (= 16) pages, we always
tried to acquire AccessExclusiveLock on it even if there was no empty pages
at the end.

Report by Simon Riggs. Back-patch all the way to 7.4.

50wu/gpdb,jmcatamney/gpdb,lintzc/gpdb,xuegang/gpdb,Quikling/gpdb,yuanzhao/gpdb,ashwinstar/gpdb,xuegang/gpdb,Quikling/gpdb,royc1/gpdb,xinzweb/gpdb,jmcatamney/gpdb,jmcatamney/gpdb,jmcatamney/gpdb,kaknikhil/gpdb,ashwinstar/gpdb,lisakowen/gpdb,CraigHarris/gpdb,ahachete/gpdb,zaksoup/gpdb,xuegang/gpdb,yuanzhao/gpdb,50wu/gpdb,rvs/gpdb,adam8157/gpdb,ashwinstar/gpdb,ashwinstar/gpdb,ashwinstar/gpdb,janebeckman/gpdb,lintzc/gpdb,lintzc/gpdb,0x0FFF/gpdb,rvs/gpdb,rvs/gpdb,Quikling/gpdb,xinzweb/gpdb,adam8157/gpdb,ashwinstar/gpdb,lisakowen/gpdb,zaksoup/gpdb,edespino/gpdb,cjcjameson/gpdb,greenplum-db/gpdb,royc1/gpdb,lisakowen/gpdb,zaksoup/gpdb,cjcjameson/gpdb,edespino/gpdb,rvs/gpdb,Chibin/gpdb,cjcjameson/gpdb,Chibin/gpdb,xuegang/gpdb,kaknikhil/gpdb,yuanzhao/gpdb,adam8157/gpdb,lisakowen/gpdb,Chibin/gpdb,kaknikhil/gpdb,0x0FFF/gpdb,Quikling/gpdb,ashwinstar/gpdb,Quikling/gpdb,yuanzhao/gpdb,yuanzhao/gpdb,0x0FFF/gpdb,adam8157/gpdb,edespino/gpdb,0x0FFF/gpdb,ahachete/gpdb,zaksoup/gpdb,0x0FFF/gpdb,0x0FFF/gpdb,edespino/gpdb,chrishajas/gpdb,Quikling/gpdb,chrishajas/gpdb,adam8157/gpdb,janebeckman/gpdb,yuanzhao/gpdb,jmcatamney/gpdb,50wu/gpdb,yuanzhao/gpdb,janebeckman/gpdb,lintzc/gpdb,50wu/gpdb,chrishajas/gpdb,edespino/gpdb,50wu/gpdb,yuanzhao/gpdb,jmcatamney/gpdb,Quikling/gpdb,lisakowen/gpdb,CraigHarris/gpdb,janebeckman/gpdb,royc1/gpdb,rvs/gpdb,kaknikhil/gpdb,cjcjameson/gpdb,50wu/gpdb,lisakowen/gpdb,royc1/gpdb,kaknikhil/gpdb,Chibin/gpdb,rvs/gpdb,greenplum-db/gpdb,yuanzhao/gpdb,royc1/gpdb,kaknikhil/gpdb,ahachete/gpdb,xinzweb/gpdb,greenplum-db/gpdb,janebeckman/gpdb,royc1/gpdb,adam8157/gpdb,cjcjameson/gpdb,janebeckman/gpdb,lintzc/gpdb,chrishajas/gpdb,kaknikhil/gpdb,ahachete/gpdb,Quikling/gpdb,zaksoup/gpdb,xuegang/gpdb,Quikling/gpdb,janebeckman/gpdb,janebeckman/gpdb,greenplum-db/gpdb,yuanzhao/gpdb,kaknikhil/gpdb,greenplum-db/gpdb,zaksoup/gpdb,50wu/gpdb,lintzc/gpdb,royc1/gpdb,rvs/gpdb,Chibin/gpdb,lisakowen/gpdb,CraigHarris/gpdb,cjcjameson/gpdb,xuegang/gpdb,xinzweb/gpdb,rvs/gpdb,ahachete/gpdb,royc1/gpdb,xinzweb/gpdb,kaknikhil/gpdb,edespino/gpdb,zaksoup/gpdb,CraigHarris/gpdb,Chibin/gpdb,CraigHarris/gpdb,edespino/gpdb,adam8157/gpdb,cjcjameson/gpdb,greenplum-db/gpdb,50wu/gpdb,CraigHarris/gpdb,rvs/gpdb,CraigHarris/gpdb,ahachete/gpdb,edespino/gpdb,0x0FFF/gpdb,xinzweb/gpdb,CraigHarris/gpdb,lintzc/gpdb,ashwinstar/gpdb,CraigHarris/gpdb,Chibin/gpdb,adam8157/gpdb,janebeckman/gpdb,cjcjameson/gpdb,chrishajas/gpdb,cjcjameson/gpdb,xuegang/gpdb,kaknikhil/gpdb,xinzweb/gpdb,janebeckman/gpdb,lintzc/gpdb,rvs/gpdb,0x0FFF/gpdb,greenplum-db/gpdb,jmcatamney/gpdb,greenplum-db/gpdb,ahachete/gpdb,cjcjameson/gpdb,zaksoup/gpdb,jmcatamney/gpdb,Chibin/gpdb,lisakowen/gpdb,Chibin/gpdb,ahachete/gpdb,edespino/gpdb,chrishajas/gpdb,Quikling/gpdb,Chibin/gpdb,chrishajas/gpdb,edespino/gpdb,xuegang/gpdb,xinzweb/gpdb,chrishajas/gpdb,xuegang/gpdb,lintzc/gpdb