diff --git a/src/backend/access/transam/twophase.c b/src/backend/access/transam/twophase.c index 5415604993..192ee065d5 100644 --- a/src/backend/access/transam/twophase.c +++ b/src/backend/access/transam/twophase.c @@ -1651,6 +1651,16 @@ CheckPointTwoPhase(XLogRecPtr redo_horizon) "for long-running prepared transactions", serialized_xacts, serialized_xacts))); + + /* + * Make sure that the content created is persistent on disk to prevent + * data loss in case of an OS crash or a power failure. Each 2PC file + * has been already created and flushed to disk individually by + * RecreateTwoPhaseFile() using the list of GXACTs available for + * normal processing as well as at recovery when replaying individually + * each XLOG_XACT_PREPARE record. + */ + fsync_fname(TWOPHASE_DIR, true); } /*