diff --git a/src/backend/access/transam/xact.c b/src/backend/access/transam/xact.c index 9a918c9b4e3..0c4efebef79 100644 --- a/src/backend/access/transam/xact.c +++ b/src/backend/access/transam/xact.c @@ -1925,6 +1925,14 @@ CommitTransaction(void) /* close large objects before lower-level cleanup */ AtEOXact_LargeObject(true); + /* + * Insert notifications sent by NOTIFY commands into the queue. This + * should be late in the pre-commit sequence to minimize time spent + * holding the notify-insertion lock. However, this could result in + * creating a snapshot, so we must do it before serializable cleanup. + */ + PreCommit_Notify(); + /* * Mark serializable transaction as complete for predicate locking * purposes. This should be done as late as we can put it and still allow @@ -1932,13 +1940,6 @@ CommitTransaction(void) */ PreCommit_CheckForSerializationFailure(); - /* - * Insert notifications sent by NOTIFY commands into the queue. This - * should be late in the pre-commit sequence to minimize time spent - * holding the notify-insertion lock. - */ - PreCommit_Notify(); - /* Prevent cancel/die interrupt while cleaning up */ HOLD_INTERRUPTS(); @@ -2127,6 +2128,8 @@ PrepareTransaction(void) /* close large objects before lower-level cleanup */ AtEOXact_LargeObject(true); + /* NOTIFY requires no work at this point */ + /* * Mark serializable transaction as complete for predicate locking * purposes. This should be done as late as we can put it and still allow @@ -2134,8 +2137,6 @@ PrepareTransaction(void) */ PreCommit_CheckForSerializationFailure(); - /* NOTIFY will be handled below */ - /* * Don't allow PREPARE TRANSACTION if we've accessed a temporary table in * this transaction. Having the prepared xact hold locks on another