Close all files before trying to remove them

pull/2090/head
Brian Cloutier 2018-04-12 19:20:37 -07:00 committed by Brian Cloutier
parent c5f1235090
commit 8d4c4d5c58
1 changed files with 12 additions and 1 deletions

View File

@ -30,6 +30,7 @@
#include "utils/hsearch.h" #include "utils/hsearch.h"
#include "utils/guc.h" #include "utils/guc.h"
#include "utils/memutils.h" #include "utils/memutils.h"
#include "storage/fd.h"
CoordinatedTransactionState CurrentCoordinatedTransactionState = COORD_TRANS_NONE; CoordinatedTransactionState CurrentCoordinatedTransactionState = COORD_TRANS_NONE;
@ -195,7 +196,17 @@ CoordinatedTransactionCallback(XactEvent event, void *arg)
* transaction management. Do so before doing other work, so the * transaction management. Do so before doing other work, so the
* callbacks still can perform work if needed. * callbacks still can perform work if needed.
*/ */
SwallowErrors(RemoveIntermediateResultsDirectory); {
/*
* On Windows it's not possible to delete a file before you've closed all
* handles to it (rmdir will return success but not take effect). Since
* we're in an ABORT handler it's very likely that not all handles have
* been closed; force them closed here before running
* RemoveIntermediateResultsDirectory.
*/
AtEOXact_Files();
SwallowErrors(RemoveIntermediateResultsDirectory);
}
ResetShardPlacementTransactionState(); ResetShardPlacementTransactionState();
/* handles both already prepared and open transactions */ /* handles both already prepared and open transactions */