On Tue, Aug 03, 2021 at 09:29:48AM +0000, liuhuail...@fujitsu.com wrote:
> There was a problem with the before patch when testing.  
> So resubmit it.

FWIW, I see no problems with patch version 1 or 2, as long as you
apply patch version 1 with a command like patch -p2.  One thing of
patch 2 is that git diff --check complains because of a whitespace.

Anyway, I also think that you are right here and that there is no need
to run this code path with ROLLBACK PREPARED.  It is worth noting that
the point of Tom about local invalidation messages in PREPARE comes
from PostPrepare_Inval().

I would just tweak the comment block at the top of what's being
changed, as per the attached.  Please let me know if there are any
objections. 
--
Michael
diff --git a/src/backend/access/transam/twophase.c b/src/backend/access/transam/twophase.c
index 6d3efb49a4..2156de187c 100644
--- a/src/backend/access/transam/twophase.c
+++ b/src/backend/access/transam/twophase.c
@@ -1520,13 +1520,17 @@ FinishPreparedTransaction(const char *gid, bool isCommit)
 	 * Handle cache invalidation messages.
 	 *
 	 * Relcache init file invalidation requires processing both before and
-	 * after we send the SI messages. See AtEOXact_Inval()
+	 * after we send the SI messages, only when committing.  See
+	 * AtEOXact_Inval().
 	 */
-	if (hdr->initfileinval)
-		RelationCacheInitFilePreInvalidate();
-	SendSharedInvalidMessages(invalmsgs, hdr->ninvalmsgs);
-	if (hdr->initfileinval)
-		RelationCacheInitFilePostInvalidate();
+	if (isCommit)
+	{
+		if (hdr->initfileinval)
+			RelationCacheInitFilePreInvalidate();
+		SendSharedInvalidMessages(invalmsgs, hdr->ninvalmsgs);
+		if (hdr->initfileinval)
+			RelationCacheInitFilePostInvalidate();
+	}
 
 	/*
 	 * Acquire the two-phase lock.  We want to work on the two-phase callbacks

Attachment: signature.asc
Description: PGP signature

Reply via email to