@@ -1944,14 +1944,6 @@ CommitTransaction(void)
19441944 */
19451945AtEOXact_Inval (true);
19461946
1947- /*
1948- * Likewise, dropping of files deleted during the transaction is best done
1949- * after releasing relcache and buffer pins. (This is not strictly
1950- * necessary during commit, since such pins should have been released
1951- * already, but this ordering is definitely critical during abort.)
1952- */
1953- smgrDoPendingDeletes (true);
1954-
19551947AtEOXact_MultiXact ();
19561948
19571949ResourceOwnerRelease (TopTransactionResourceOwner ,
@@ -1961,6 +1953,17 @@ CommitTransaction(void)
19611953RESOURCE_RELEASE_AFTER_LOCKS ,
19621954 true, true);
19631955
1956+ /*
1957+ * Likewise, dropping of files deleted during the transaction is best done
1958+ * after releasing relcache and buffer pins. (This is not strictly
1959+ * necessary during commit, since such pins should have been released
1960+ * already, but this ordering is definitely critical during abort.) Since
1961+ * this may take many seconds, also delay until after releasing locks.
1962+ * Other backends will observe the attendant catalog changes and not
1963+ * attempt to access affected files.
1964+ */
1965+ smgrDoPendingDeletes (true);
1966+
19641967/* Check we've released all catcache entries */
19651968AtEOXact_CatCache (true);
19661969
@@ -2354,14 +2357,14 @@ AbortTransaction(void)
23542357AtEOXact_Buffers (false);
23552358AtEOXact_RelationCache (false);
23562359AtEOXact_Inval (false);
2357- smgrDoPendingDeletes (false);
23582360AtEOXact_MultiXact ();
23592361ResourceOwnerRelease (TopTransactionResourceOwner ,
23602362RESOURCE_RELEASE_LOCKS ,
23612363 false, true);
23622364ResourceOwnerRelease (TopTransactionResourceOwner ,
23632365RESOURCE_RELEASE_AFTER_LOCKS ,
23642366 false, true);
2367+ smgrDoPendingDeletes (false);
23652368AtEOXact_CatCache (false);
23662369
23672370AtEOXact_GUC (false,1 );
@@ -4238,13 +4241,13 @@ AbortSubTransaction(void)
42384241AtEOSubXact_RelationCache (false,s -> subTransactionId ,
42394242s -> parent -> subTransactionId );
42404243AtEOSubXact_Inval (false);
4241- AtSubAbort_smgr ();
42424244ResourceOwnerRelease (s -> curTransactionOwner ,
42434245RESOURCE_RELEASE_LOCKS ,
42444246 false, false);
42454247ResourceOwnerRelease (s -> curTransactionOwner ,
42464248RESOURCE_RELEASE_AFTER_LOCKS ,
42474249 false, false);
4250+ AtSubAbort_smgr ();
42484251
42494252AtEOXact_GUC (false,s -> gucNestLevel );
42504253AtEOSubXact_SPI (false,s -> subTransactionId );