@@ -1944,14 +1944,6 @@ CommitTransaction(void)
1944
1944
*/
1945
1945
AtEOXact_Inval (true);
1946
1946
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
-
1955
1947
AtEOXact_MultiXact ();
1956
1948
1957
1949
ResourceOwnerRelease (TopTransactionResourceOwner ,
@@ -1961,6 +1953,17 @@ CommitTransaction(void)
1961
1953
RESOURCE_RELEASE_AFTER_LOCKS ,
1962
1954
true, true);
1963
1955
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
+
1964
1967
/* Check we've released all catcache entries */
1965
1968
AtEOXact_CatCache (true);
1966
1969
@@ -2354,14 +2357,14 @@ AbortTransaction(void)
2354
2357
AtEOXact_Buffers (false);
2355
2358
AtEOXact_RelationCache (false);
2356
2359
AtEOXact_Inval (false);
2357
- smgrDoPendingDeletes (false);
2358
2360
AtEOXact_MultiXact ();
2359
2361
ResourceOwnerRelease (TopTransactionResourceOwner ,
2360
2362
RESOURCE_RELEASE_LOCKS ,
2361
2363
false, true);
2362
2364
ResourceOwnerRelease (TopTransactionResourceOwner ,
2363
2365
RESOURCE_RELEASE_AFTER_LOCKS ,
2364
2366
false, true);
2367
+ smgrDoPendingDeletes (false);
2365
2368
AtEOXact_CatCache (false);
2366
2369
2367
2370
AtEOXact_GUC (false, 1 );
@@ -4238,13 +4241,13 @@ AbortSubTransaction(void)
4238
4241
AtEOSubXact_RelationCache (false, s -> subTransactionId ,
4239
4242
s -> parent -> subTransactionId );
4240
4243
AtEOSubXact_Inval (false);
4241
- AtSubAbort_smgr ();
4242
4244
ResourceOwnerRelease (s -> curTransactionOwner ,
4243
4245
RESOURCE_RELEASE_LOCKS ,
4244
4246
false, false);
4245
4247
ResourceOwnerRelease (s -> curTransactionOwner ,
4246
4248
RESOURCE_RELEASE_AFTER_LOCKS ,
4247
4249
false, false);
4250
+ AtSubAbort_smgr ();
4248
4251
4249
4252
AtEOXact_GUC (false, s -> gucNestLevel );
4250
4253
AtEOSubXact_SPI (false, s -> subTransactionId );
0 commit comments