Force a checkpoint in CREATE DATABASE before starting to copy the files, to process any pending unlinks for the source database.
Force a checkpoint in CREATE DATABASE before starting to copy the files,
to process any pending unlinks for the source database.

Before, if you dropped a relation in the template database just before
CREATE DATABASE, and a checkpoint happened during copydir(), the checkpoint
might delete a file that we're just about to copy, causing lstat() in
copydir() to fail with ENOENT.

Backpatch to 8.3, where the pending unlinks were introduced.

Per report by Matthew Wakeling and analysis by Tom Lane.

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