Skip to content

Commit 710796f

Browse files
committed
Avoid unnecessary shared invalidations in ROLLBACK PREPARED
The performance gain is minimal, but this makes the logic more consistent with AtEOXact_Inval(). No other invalidation is needed in this case as PREPARE takes already care of sending any local ones. Author: Liu Huailing Reviewed-by: Tom Lane, Michael Paquier Discussion: https://postgr.es/m/OSZPR01MB6215AA84D71EF2B3D354CF86BE139@OSZPR01MB6215.jpnprd01.prod.outlook.com
1 parent c3928b4 commit 710796f

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/backend/access/transam/twophase.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1520,13 +1520,17 @@ FinishPreparedTransaction(const char *gid, bool isCommit)
15201520
* Handle cache invalidation messages.
15211521
*
15221522
* Relcache init file invalidation requires processing both before and
1523-
* after we send the SI messages. See AtEOXact_Inval()
1523+
* after we send the SI messages, only when committing. See
1524+
* AtEOXact_Inval().
15241525
*/
1525-
if (hdr->initfileinval)
1526-
RelationCacheInitFilePreInvalidate();
1527-
SendSharedInvalidMessages(invalmsgs, hdr->ninvalmsgs);
1528-
if (hdr->initfileinval)
1529-
RelationCacheInitFilePostInvalidate();
1526+
if (isCommit)
1527+
{
1528+
if (hdr->initfileinval)
1529+
RelationCacheInitFilePreInvalidate();
1530+
SendSharedInvalidMessages(invalmsgs, hdr->ninvalmsgs);
1531+
if (hdr->initfileinval)
1532+
RelationCacheInitFilePostInvalidate();
1533+
}
15301534

15311535
/*
15321536
* Acquire the two-phase lock. We want to work on the two-phase callbacks

0 commit comments

Comments
 (0)