Move call to RemoveIntermediateResultsDirectory

Errors thrown in the COMMIT handler will cause Postgres to segfault,
there's nothing it can do it abort the transaction by the time that
handler is called!

RemoveIntermediateResultsDirectory is problematic for two reasons:
- It has calls to ereport(ERROR which have been known to trigger
- It makes memory allocations which raise ERRORs when they fail

Once the COMMIT process has begun we don't use the intermediate results,
so it's safe to remove them a little earlier in the process. A failure
here will abort the transaction. That's pretty unnecessary, it's not
that important that we remove the results, but it's still better than a
crash.
pull/2161/head
Brian Cloutier 2018-05-09 12:59:48 -07:00
parent b3e85e4f71
commit 4c2bf5d2d6
1 changed files with 2 additions and 1 deletions

View File

@ -159,7 +159,6 @@ CoordinatedTransactionCallback(XactEvent event, void *arg)
* transaction management. Do so before doing other work, so the
* callbacks still can perform work if needed.
*/
RemoveIntermediateResultsDirectory();
ResetShardPlacementTransactionState();
if (CurrentCoordinatedTransactionState == COORD_TRANS_PREPARED)
@ -256,6 +255,8 @@ CoordinatedTransactionCallback(XactEvent event, void *arg)
case XACT_EVENT_PRE_COMMIT:
{
RemoveIntermediateResultsDirectory();
/* nothing further to do if there's no managed remote xacts */
if (CurrentCoordinatedTransactionState == COORD_TRANS_NONE)
{