diff options
author | Michael Paquier <michael@paquier.xyz> | 2021-08-12 20:12:47 +0900 |
---|---|---|
committer | Michael Paquier <michael@paquier.xyz> | 2021-08-12 20:12:47 +0900 |
commit | 710796f0542180cca18ee93889da692df642bdf2 (patch) | |
tree | 242a175047a7df55c02b0ebe347915b486d9f8d1 | |
parent | c3928b467a4f0ed2b0ef21a33848e9fcdade37b4 (diff) | |
download | postgresql-710796f0542180cca18ee93889da692df642bdf2.tar.gz postgresql-710796f0542180cca18ee93889da692df642bdf2.zip |
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
-rw-r--r-- | src/backend/access/transam/twophase.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/backend/access/transam/twophase.c b/src/backend/access/transam/twophase.c index 6d3efb49a40..2156de187c3 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 |