8000 Accept pg_upgraded tuples during multixact freezing · postgres/postgres@a25c2b7 · GitHub
[go: up one dir, main page]

Skip to content
{"payload":{"commit":{"oid":"a25c2b7c4db3b4542e05d660e55bef5c93fdc32d","url":"/postgres/postgres/commit/a25c2b7c4db3b4542e05d660e55bef5c93fdc32d","authoredDate":"2014-01-10T18:03:18.000-03:00","committedDate":"2014-01-10T18:03:18.000-03:00","shortMessage":null,"shortMessageMarkdown":"\u003cdiv\u003eAccept pg_upgraded tuples during multixact freezing\u003c/div\u003e","shortMessageMarkdownLink":null,"bodyMessageHtml":"The new MultiXact freezing routines introduced by commit \u003ca class=\"commit-link\" data-hovercard-type=\"commit\" data-hovercard-url=\"https://github.com/postgres/postgres/commit/8e9a16ab8f7f0e5813644975cc3f336e5b064b6e/hovercard\" href=\"https://github.com/postgres/postgres/commit/8e9a16ab8f7f0e5813644975cc3f336e5b064b6e\"\u003e\u003ctt\u003e8e9a16a\u003c/tt\u003e\u003c/a\u003e\nneglected to consider tuples that came from a pg_upgrade'd database; a\nvacuum run that tried to freeze such tuples would die with an error such\nas\nERROR: MultiXactId 11415437 does no longer exist -- apparent wraparound\n\nTo fix, ensure that GetMultiXactIdMembers is allowed to return empty\nmultis when the infomask bits are right, as is done in other callsites.\n\nPer trouble report from F-Secure.\n\nIn passing, fix a copy\u0026amp;paste bug reported by Andrey Karpov from VIVA64\nfrom their PVS-Studio static checked, that instead of setting relminmxid\nto Invalid, we were setting relfrozenxid twice. Not an important\nmistake because that code branch is about relations for which we don't\nuse the frozenxid/minmxid values at all in the first place, but seems to\nwarrants a fix nonetheless.","authors":[{"login":"alvherre","displayName":"Alvaro Herrera","avatarUrl":"https://avatars.githubusercontent.com/u/340005?v=4","path":"/alvherre","isGitHub":false}],"committerAttribution":false,"committer":{"login":"alvherre","displayName":"Alvaro Herrera","avatarUrl":"https://avatars.githubusercontent.com/u/340005?v=4","path":"/alvherre","isGitHub":false},"parents":["28fff0ef8b1fadc105aaf28e224e8a5e87866875"],"globalRelayId":"MDY6Q29tbWl0OTI3NDQyOmEyNWMyYjdjNGRiM2I0NTQyZTA1ZDY2MGU1NWJlZjVjOTNmZGMzMmQ=","sha1":"28fff0ef8b1fadc105aaf28e224e8a5e87866875","sha2":"a25c2b7c4db3b4542e05d660e55bef5c93fdc32d"},"currentUser":null,"repo":{"id":927442,"defaultBranch":"master","name":"postgres","ownerLogin":"postgres","currentUserCanPush":false,"isFork":false,"isEmpty":false,"createdAt":"2010-09-21T11:35:45.000Z","ownerAvatar":"https://avatars.githubusercontent.com/u/177543?v=4","public":true,"private":false,"isOrgOwned":true},"diffEntryData":[{"diffLines":[{"stylingDirective":null,"type":"HUNK","blobLineNumber":5287,"text":"@@ -5288,6 +5288,7 @@ FreezeMultiXactId(MultiXactId multi, uint16 t_infomask,","html":"@@ -5288,6 +5288,7 @@ FreezeMultiXactId(MultiXactId multi, uint16 t_infomask,","displayNoNewLineWarning":false,"position":0,"left":5287,"right":5287},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":5288,"text":" \tbool\t\thas_lockers;","html":" \t\u003cspan class=pl-smi\u003ebool\u003c/span\u003e\t\t\u003cspan class=pl-s1\u003ehas_lockers\u003c/span\u003e;","displayNoNewLineWarning":false,"position":1,"left":5288,"right":5288},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":5289,"text":" \tTransactionId update_xid;","html":" \t\u003cspan class=pl-smi\u003eTransactionId\u003c/span\u003e \u003cspan class=pl-s1\u003eupdate_xid\u003c/span\u003e;","displayNoNewLineWarning":false,"position":2,"left":5289,"right":5289},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":5290,"text":" \tbool\t\tupdate_committed;","html":" \t\u003cspan class=pl-smi\u003ebool\u003c/span\u003e\t\t\u003cspan class=pl-s1\u003eupdate_committed\u003c/span\u003e;","displayNoNewLineWarning":false,"position":3,"left":5290,"right":5290},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":5291,"text":"+\tbool\t\tallow_old;","html":"+\t\u003cspan class=pl-smi\u003ebool\u003c/span\u003e\t\t\u003cspan class=pl-s1\u003eallow_old\u003c/span\u003e;","displayNoNewLineWarning":false,"position":4,"left":5290,"right":5291},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":5292,"text":" ","html":"\u003cbr\u003e","displayNoNewLineWarning":false,"position":5,"left":5291,"right":5292},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":5293,"text":" \t*flags = 0;","html":" \t\u003cspan class=pl-c1\u003e*\u003c/span\u003e\u003cspan class=pl-s1\u003eflags\u003c/span\u003e \u003cspan class=pl-c1\u003e=\u003c/span\u003e \u003cspan class=pl-c1\u003e0\u003c/span\u003e;","displayNoNewLineWarning":false,"position":6,"left":5292,"right":5293},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":5294,"text":" ","html":"\u003cbr\u003e","displayNoNewLineWarning":false,"position":7,"left":5293,"right":5294},{"stylingDirective":null,"type":"HUNK","blobLineNumber":5349,"text":"@@ -5349,7 +5350,9 @@ FreezeMultiXactId(MultiXactId multi, uint16 t_infomask,","html":"@@ -5349,7 +5350,9 @@ FreezeMultiXactId(MultiXactId multi, uint16 t_infomask,","displayNoNewLineWarning":false,"position":8,"left":5348,"right":5349},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":5350,"text":" \t * anything.","html":" \u003cspan class=pl-c\u003e\t * anything.\u003c/span\u003e","displayNoNewLineWarning":false,"position":9,"left":5349,"right":5350},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":5351,"text":" \t */","html":" \u003cspan class=pl-c\u003e\t */\u003c/span\u003e","displayNoNewLineWarning":false,"position":10,"left":5350,"right":5351},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":5352,"text":" ","html":"\u003cbr\u003e","displayNoNewLineWarning":false,"position":11,"left":5351,"right":5352},{"stylingDirective":null,"type":"DELETION","blobLineNumber":5352,"text":"-\tnmembers = GetMultiXactIdMembers(multi, \u0026members, false);","html":"-\t\u003cspan class=pl-s1\u003enmembers\u003c/span\u003e \u003cspan class=pl-c1\u003e=\u003c/span\u003e \u003cspan class=pl-en\u003eGetMultiXactIdMembers\u003c/span\u003e(\u003cspan class=pl-s1\u003emulti\u003c/span\u003e, \u003cspan class=pl-c1\u003e\u0026amp;\u003c/span\u003e\u003cspan class=pl-s1\u003emembers\u003c/span\u003e, false);","displayNoNewLineWarning":false,"position":12,"left":5352,"right":5352},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":5353,"text":"+\tallow_old = !(t_infomask \u0026 HEAP_LOCK_MASK) \u0026\u0026","html":"+\t\u003cspan class=pl-s1\u003eallow_old\u003c/span\u003e \u003cspan class=pl-c1\u003e=\u003c/span\u003e !(\u003cspan class=pl-s1\u003et_infomask\u003c/span\u003e \u003cspan class=pl-c1\u003e\u0026amp;\u003c/span\u003e \u003cspan class=pl-c1\u003eHEAP_LOCK_MASK\u003c/span\u003e) \u003cspan class=pl-c1\u003e\u0026amp;\u0026amp;\u003c/span\u003e","displayNoNewLineWarning":false,"position":13,"left":5352,"right":5353},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":5354,"text":"+\t\tHEAP_XMAX_IS_LOCKED_ONLY(t_infomask);","html":"+\t\t\u003cspan class=pl-en\u003eHEAP_XMAX_IS_LOCKED_ONLY\u003c/span\u003e(\u003cspan class=pl-s1\u003et_infomask\u003c/span\u003e);","displayNoNewLineWarning":false,"position":14,"left":5352,"right":5354},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":5355,"text":"+\tnmembers = GetMultiXactIdMembers(multi, \u0026members, allow_old);","html":"+\t\u003cspan class=pl-s1\u003enmembers\u003c/span\u003e \u003cspan class=pl-c1\u003e=\u003c/span\u003e \u003cspan class=pl-en\u003eGetMultiXactIdMembers\u003c/span\u003e(\u003cspan class=pl-s1\u003emulti\u003c/span\u003e, \u003cspan class=pl-c1\u003e\u0026amp;\u003c/span\u003e\u003cspan class=pl-s1\u003emembers\u003c/span\u003e, \u003cspan class=pl-s1\u003eallow_old\u003c/span\u003e);","displayNoNewLineWarning":false,"position":15,"left":5352,"right":5355},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":5356,"text":" \tif (nmembers \u003c= 0)","html":" \t\u003cspan class=pl-k\u003eif\u003c/span\u003e (\u003cspan class=pl-s1\u003enmembers\u003c/span\u003e \u0026lt;= \u003cspan class=pl-c1\u003e0\u003c/span\u003e)","displayNoNewLineWarning":false,"position":16,"left":5353,"right":5356},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":5357,"text":" \t{","html":" \t{","displayNoNewLineWarning":false,"position":17,"left":5354,"right":5357},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":5358,"text":" \t\t/* Nothing worth keeping */","html":" \t\t\u003cspan class=pl-c\u003e/* Nothing worth keeping */\u003c/span\u003e","displayNoNewLineWarning":false,"position":18,"left":5355,"right":5358},{"stylingDirective":null,"type":"HUNK","blobLineNumber":6062,"text":"@@ -6060,10 +6063,13 @@ heap_tuple_needs_freeze(HeapTupleHeader tuple, TransactionId cutoff_xid,","html":"@@ -6060,10 +6063,13 @@ heap_tuple_needs_freeze(HeapTupleHeader tuple, TransactionId cutoff_xid,","displayNoNewLineWarning":false,"position":19,"left":6059,"right":6062},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":6063,"text":" \t\t\tMultiXactMember *members;","html":" \t\t\t\u003cspan class=pl-smi\u003eMultiXactMember\u003c/span\u003e \u003cspan class=pl-c1\u003e*\u003c/span\u003e\u003cspan class=pl-s1\u003emembers\u003c/span\u003e;","displayNoNewLineWarning":false,"position":20,"left":6060,"right":6063},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":6064,"text":" \t\t\tint\t\t\tnmembers;","html":" \t\t\t\u003cspan class=pl-smi\u003eint\u003c/span\u003e\t\t\t\u003cspan class=pl-s1\u003enmembers\u003c/span\u003e;","displayNoNewLineWarning":false,"position":21,"left":6061,"right":6064},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":6065,"text":" \t\t\tint\t\t\ti;","html":" \t\t\t\u003cspan class=pl-smi\u003eint\u003c/span\u003e\t\t\t\u003cspan class=pl-s1\u003ei\u003c/span\u003e;","displayNoNewLineWarning":false,"position":22,"left":6062,"right":6065},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":6066,"text":"+\t\t\tbool\t\tallow_old;","html":"+\t\t\t\u003cspan class=pl-smi\u003ebool\u003c/span\u003e\t\t\u003cspan class=pl-s1\u003eallow_old\u003c/span\u003e;","displayNoNewLineWarning":false,"position":23,"left":6062,"right":6066},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":6067,"text":" ","html":"\u003cbr\u003e","displayNoNewLineWarning":false,"position":24,"left":6063,"right":6067},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":6068,"text":" \t\t\t/* need to check whether any member of the mxact is too old */","html":" \t\t\t\u003cspan class=pl-c\u003e/* need to check whether any member of the mxact is too old */\u003c/span\u003e","displayNoNewLineWarning":false,"position":25,"left":6064,"right":6068},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":6069,"text":" ","html":"\u003cbr\u003e","displayNoNewLineWarning":false,"position":26,"left":6065,"right":6069},{"stylingDirective":null,"type":"DELETION","blobLineNumber":6066,"text":"-\t\t\tnmembers = GetMultiXactIdMembers(multi, \u0026members, false);","html":"-\t\t\t\u003cspan class=pl-s1\u003enmembers\u003c/span\u003e \u003cspan class=pl-c1\u003e=\u003c/span\u003e \u003cspan class=pl-en\u003eGetMultiXactIdMembers\u003c/span\u003e(\u003cspan class=pl-s1\u003emulti\u003c/span\u003e, \u003cspan class=pl-c1\u003e\u0026amp;\u003c/span\u003e\u003cspan class=pl-s1\u003emembers\u003c/span\u003e, false);","displayNoNewLineWarning":false,"position":27,"left":6066,"right":6069},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":6070,"text":"+\t\t\tallow_old = !(tuple-\u003et_infomask \u0026 HEAP_LOCK_MASK) \u0026\u0026","html":"+\t\t\t\u003cspan class=pl-s1\u003eallow_old\u003c/span\u003e \u003cspan class=pl-c1\u003e=\u003c/span\u003e !(\u003cspan class=pl-s1\u003etuple\u003c/span\u003e\u003cspan class=pl-c1\u003e-\u0026gt;\u003c/span\u003e\u003cspan class=pl-c1\u003et_infomask\u003c/span\u003e \u003cspan class=pl-c1\u003e\u0026amp;\u003c/span\u003e \u003cspan class=pl-c1\u003eHEAP_LOCK_MASK\u003c/span\u003e) \u003cspan class=pl-c1\u003e\u0026amp;\u0026amp;\u003c/span\u003e","displayNoNewLineWarning":false,"position":28,"left":6066,"right":6070},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":6071,"text":"+\t\t\t\tHEAP_XMAX_IS_LOCKED_ONLY(tuple-\u003et_infomask);","html":"+\t\t\t\t\u003cspan class=pl-en\u003eHEAP_XMAX_IS_LOCKED_ONLY\u003c/span\u003e(\u003cspan class=pl-s1\u003etuple\u003c/span\u003e\u003cspan class=pl-c1\u003e-\u0026gt;\u003c/span\u003e\u003cspan class=pl-c1\u003et_infomask\u003c/span\u003e);","displayNoNewLineWarning":false,"position":29,"left":6066,"right":6071},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":6072,"text":"+\t\t\tnmembers = GetMultiXactIdMembers(multi, \u0026members, allow_old);","html":"+\t\t\t\u003cspan class=pl-s1\u003enmembers\u003c/span\u003e \u003cspan class=pl-c1\u003e=\u003c/span\u003e \u003cspan class=pl-en\u003eGetMultiXactIdMembers\u003c/span\u003e(\u003cspan class=pl-s1\u003emulti\u003c/span\u003e, \u003cspan class=pl-c1\u003e\u0026amp;\u003c/span\u003e\u003cspan class=pl-s1\u003emembers\u003c/span\u003e, \u003cspan class=pl-s1\u003eallow_old\u003c/span\u003e);","displayNoNewLineWarning":false,"position":30,"left":6066,"right":6072},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":6073,"text":" ","html":"\u003cbr\u003e","displayNoNewLineWarning":false,"position":31,"left":6067,"right":6073},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":6074,"text":" \t\t\tfor (i = 0; i \u003c nmembers; i++)","html":" \t\t\t\u003cspan class=pl-k\u003efor\u003c/span\u003e (\u003cspan class=pl-s1\u003ei\u003c/span\u003e \u003cspan class=pl-c1\u003e=\u003c/span\u003e \u003cspan class=pl-c1\u003e0\u003c/span\u003e; \u003cspan class=pl-s1\u003ei\u003c/span\u003e \u003cspan class=pl-c1\u003e\u0026lt;\u003c/span\u003e \u003cspan class=pl-s1\u003enmembers\u003c/span\u003e; \u003cspan class=pl-s1\u003ei\u003c/span\u003e\u003cspan class=pl-c1\u003e++\u003c/span\u003e)","displayNoNewLineWarning":false,"position":32,"left":6068,"right":6074},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":6075,"text":" \t\t\t{","html":" \t\t\t{","displayNoNewLineWarning":false,"position":33,"left":6069,"right":6075}],"diffNumber":0,"diffSize":"0 Bytes","isBinary":false,"isTooBig":false,"collapsed":false,"isSubmodule":false,"lineCount":7947,"linesChanged":10,"newTreeEntry":{"lineCount":7947,"path":"src/backend/access/heap/heapam.c","mode":100644,"isGenerated":false},"oldTreeEntry":{"lineCount":0,"path":"src/backend/access/heap/heapam.c","mode":100644},"linesAdded":8,"linesDeleted":2,"path":"src/backend/access/heap/heapam.c","pathDigest":"3b097bc5bff5567d6b7406cdc244c4776320db676812ead1676559914a256a0a","status":"MODIFIED","truncatedReason":null,"oldOid":"28fff0ef8b1fadc105aaf28e224e8a5e87866875","newOid":"a25c2b7c4db3b4542e05d660e55bef5c93fdc32d","copilotChatReference":null,"deletedSha":"28fff0ef8b1fadc105aaf28e224e8a5e87866875","canToggleRichDiff":false,"defaultToRichDiff":false,"proseDifffHtml":null,"renderInfo":null,"dependencyDiffPath":null,"submodule":null},{"diffLines":[{"stylingDirective":null,"type":"HUNK","blobLineNumber":902,"text":"@@ -903,7 +903,7 @@ AddNewRelationTuple(Relation pg_class_desc,","html":"@@ -903,7 +903,7 @@ AddNewRelationTuple(Relation pg_class_desc,","displayNoNewLineWarning":false,"position":0,"left":902,"right":902},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":903,"text":" \t\t * commands/sequence.c.)","html":" \u003cspan class=pl-c\u003e\t\t * commands/sequence.c.)\u003c/span\u003e","displayNoNewLineWarning":false,"position":1,"left":903,"right":903},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":904,"text":" \t\t */","html":" \u003cspan class=pl-c\u003e\t\t */\u003c/span\u003e","displayNoNewLineWarning":false,"position":2,"left":904,"right":904},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":905,"text":" \t\tnew_rel_reltup-\u003erelfrozenxid = InvalidTransactionId;","html":" \t\t\u003cspan class=pl-s1\u003enew_rel_reltup\u003c/span\u003e\u003cspan class=pl-c1\u003e-\u0026gt;\u003c/span\u003e\u003cspan class=pl-c1\u003erelfrozenxid\u003c/span\u003e \u003cspan class=pl-c1\u003e=\u003c/span\u003e \u003cspan class=pl-s1\u003eInvalidTransactionId\u003c/span\u003e;","displayNoNewLineWarning":false,"position":3,"left":905,"right":905},{"stylingDirective":null,"type":"DELETION","blobLineNumber":906,"text":"-\t\tnew_rel_reltup-\u003erelfrozenxid = InvalidMultiXactId;","html":"-\t\t\u003cspan class=\"pl-s1\"\u003enew_rel_reltup\u003c/span\u003e\u003cspan class=\"pl-c1\"\u003e-\u0026gt;\u003c/span\u003e\u003cspan class=\"pl-c1 x x-first x-last\"\u003erelfrozenxid\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e=\u003c/span\u003e \u003cspan class=\"pl-s1\"\u003eInvalidMultiXactId\u003c/span\u003e;","displayNoNewLineWarning":false,"position":4,"left":906,"right":905},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":906,"text":"+\t\tnew_rel_reltup-\u003erelminmxid = InvalidMultiXactId;","html":"+\t\t\u003cspan class=\"pl-s1\"\u003enew_rel_reltup\u003c/span\u003e\u003cspan class=\"pl-c1\"\u003e-\u0026gt;\u003c/span\u003e\u003cspan class=\"pl-c1 x x-first x-last\"\u003erelminmxid\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e=\u003c/span\u003e \u003cspan class=\"pl-s1\"\u003eInvalidMultiXactId\u003c/span\u003e;","displayNoNewLineWarning":false,"position":5,"left":906,"right":906},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":907,"text":" \t}","html":" \t}","displayNoNewLineWarning":false,"position":6,"left":907,"right":907},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":908,"text":" ","html":"\u003cbr\u003e","displayNoNewLineWarning":false,"position":7,"left":908,"right":908},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":909,"text":" \tnew_rel_reltup-\u003erelowner = relowner;","html":" \t\u003cspan class=pl-s1\u003enew_rel_reltup\u003c/span\u003e\u003cspan class=pl-c1\u003e-\u0026gt;\u003c/span\u003e\u003cspan class=pl-c1\u003erelowner\u003c/span\u003e \u003cspan class=pl-c1\u003e=\u003c/span\u003e \u003cspan class=pl-s1\u003erelowner\u003c/span\u003e;","displayNoNewLineWarning":false,"position":8,"left":909,"right":909}],"diffNumber":1,"diffSize":"0 Bytes","isBinary":false,"isTooBig":false,"collapsed":false,"isSubmodule":false,"lineCount":2950,"linesChanged":2,"newTreeEntry":{"lineCount":2950,"path":"src/backend/catalog/heap.c","mode":100644,"isGenerated":false},"oldTreeEntry":{"lineCount":0,"path":"src/backend/catalog/heap.c","mode":100644},"linesAdded":1,"linesDeleted":1,"path":"src/backend/catalog/heap.c","pathDigest":"5a6264cd54cb3f2e22f2adcd2997803d89f9494bf15fd75e4147bac30138601d","status":"MODIFIED","truncatedReason":null,"oldOid":"28fff0ef8b1fadc105aaf28e224e8a5e87866875","newOid":"a25c2b7c4db3b4542e05d660e55bef5c93fdc32d","copilotChatReference":null,"deletedSha":"28fff0ef8b1fadc105aaf28e224e8a5e87866875","canToggleRichDiff":false,"defaultToRichDiff":false,"proseDifffHtml":null,"renderInfo":null,"dependencyDiffPath":null,"submodule":null}],"splitViewPreference":"unified","ignoreWhitespace":false,"repoOwnerGlobalRelayId":"MDEyOk9yZ2FuaXphdGlvbjE3NzU0Mw==","commentsPreference":"visible","diffLineSpacingPreference":"relaxed","useMonospaceFont":false,"pasteUrlLinkAsPlainText":false,"userNotices":[],"path":"/postgres/postgres/commit/a25c2b7c4db3b4542e05d660e55bef5c93fdc32d","fileTreeExpanded":true,"headerInfo":{"additions":9,"deletions":3,"filesChanged":2,"filesChangedString":"2"},"moreDiffsToLoad":false,"asyncDiffLoadInfo":{"startIndex":2,"truncated":false,"byteCount":1394,"lineShownCount":43},"commentInfo":{"canComment":false,"locked":false,"canLock":false,"repoArchived":false},"csrf_tokens":{"/users/diffview?diff=split":{"post":"bGqh_mog9QJzjZGMvU71sFWCMVyGG1KBgr4jsTDfCFwhk3akTGDrdOeab_G85N4fyiZvBRKs-RUOPAnpVvNDag"},"/users/diffview?diff=unified":{"post":"Wf6uWJYvOcqOzrw1GpGucM27FXZmFOIUkfyQdvu9_QwUB3kCsG8nvBrZQkgbO4XfUh9LL_KjSYAdfrounZG2Og"},"/notifications/thread":{"post":"E6YIhR0d-4gjJh-L4O99K4NKA1sFpW7Jl4QWak69dIp57IwO-HIoIcNKny5uKzFi4wEw3AHBggRG9Sd3ZTYh7g"}}},"title":"Accept pg_upgraded tuples during multixact freezing · postgres/postgres@a25c2b7","appPayload":{"helpUrl":"https://docs.github.com","findInDiffWorkerPath":"/assets-cdn/worker/find-in-diff-worker-2bfe39677d14.js","enabled_features":{"diff_ux_refresh_beta":false,"diff_inline_comments":true,"diff_ux_refresh_ssr_five":false,"diff_ux_refresh_ssr_ten":false,"react_diff_line_type_character_correction":true}}}

Commit a25c2b7

Browse files
committed
Accept pg_upgraded tuples during multixact freezing
The new MultiXact freezing routines introduced by commit 8e9a16a neglected to consider tuples that came from a pg_upgrade'd database; a vacuum run that tried to freeze such tuples would die with an error such as ERROR: MultiXactId 11415437 does no longer exist -- apparent wraparound To fix, ensure that GetMultiXactIdMembers is allowed to return empty multis when the infomask bits are right, as is done in other callsites. Per trouble report from F-Secure. In passing, fix a copy&paste bug reported by Andrey Karpov from VIVA64 from their PVS-Studio static checked, that instead of setting relminmxid to Invalid, we were setting relfrozenxid twice. Not an important mistake because that code branch is about relations for which we don't use the frozenxid/minmxid values at all in the first place, but seems to warrants a fix nonetheless.
1 parent 28fff0e commit a25c2b7

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

src/backend/access/heap/heapam.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5288,6 +5288,7 @@ FreezeMultiXactId(MultiXactId multi, uint16 t_infomask,
52885288
bool has_lockers;
52895289
TransactionId update_xid;
52905290
bool update_committed;
5291+
bool allow_old;
52915292

52925293
*flags = 0;
52935294

@@ -5349,7 +5350,9 @@ FreezeMultiXactId(MultiXactId multi, uint16 t_infomask,
53495350
* anything.
53505351
*/
53515352

5352-
nmembers = GetMultiXactIdMembers(multi, &members, false);
5353+
allow_old = !(t_infomask & HEAP_LOCK_MASK) &&
5354+
HEAP_XMAX_IS_LOCKED_ONLY(t_infomask);
5355+
nmembers = GetMultiXactIdMembers(multi, &members, allow_old);
53535356
if (nmembers <= 0)
53545357
{
53555358
/* Nothing worth keeping */
@@ -6060,10 +6063,13 @@ heap_tuple_needs_freeze(HeapTupleHeader tuple, TransactionId cutoff_xid,
60606063
MultiXactMember *members;
60616064
int nmembers;
60626065
int i;
6066+
bool allow_old;
60636067

60646068
/* need to check whether any member of the mxact is too old */
60656069

6066-
nmembers = GetMultiXactIdMembers(multi, &members, false);
6070+
allow_old = !(tuple->t_infomask & HEAP_LOCK_MASK) &&
6071+
HEAP_XMAX_IS_LOCKED_ONLY(tuple->t_infomask);
6072+
nmembers = GetMultiXactIdMembers(multi, &members, allow_old);
60676073

60686074
for (i = 0; i < nmembers; i++)
60696075
{

src/backend/catalog/heap.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -903,7 +903,7 @@ AddNewRelationTuple(Relation pg_class_desc,
903903
* commands/sequence.c.)
904904
*/
905905
new_rel_reltup->relfrozenxid = InvalidTransactionId;
906-
new_rel_reltup->relfrozenxid = InvalidMultiXactId;
906+
new_rel_reltup->relminmxid = InvalidMultiXactId;
907907
}
908908

909909
new_rel_reltup->relowner = relowner;

0 commit comments

Comments
 (0)
0