Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1YnEg9-0000aL-Aw for pgsql-bugs@arkaria.postgresql.org; Tue, 28 Apr 2015 23:12:37 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1YnEg8-0003pa-N5 for pgsql-bugs@arkaria.postgresql.org; Tue, 28 Apr 2015 23:12:36 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1YnEg7-0003pR-Kr for pgsql-bugs@postgresql.org; Tue, 28 Apr 2015 23:12:35 +0000 Received: from smtprelay0183.b.hostedemail.com ([64.98.42.183] helo=smtprelay.b.hostedemail.com) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1YnEg1-0003wp-EW for pgsql-bugs@postgresql.org; Tue, 28 Apr 2015 23:12:34 +0000 Received: from filter.hostedemail.com (10.5.19.248.rfc1918.com [10.5.19.248]) by smtprelay05.b.hostedemail.com (Postfix) with ESMTP id 4978032AF8F; Tue, 28 Apr 2015 23:12:27 +0000 (UTC) X-Session-Marker: 616C76686572726540616C76682E6E6F2D69702E6F7267 X-Spam-Summary: 10, 1, 0, , d41d8cd98f00b204, alvherre@alvh.no-ip.org, :::::::::::, RULES_HIT:41:355:379:599:871:967:973:988:989:1260:1263:1311:1312:1313:1314:1345:1359:1437:1515:1516:1518:1519:1535:1538:1567:1575:1594:1595:1596:1711:1714:1730:1747:1764:1777:1792:2198:2199:2393:2525:2560:2563:2682:2685:2693:2859:2933:2937:2939:2942:2945:2947:2951:2954:3022:3138:3139:3140:3141:3142:3867:3868:3872:3934:3936:3938:3941:3944:3947:3950:3953:3956:3959:4119:4605:4659:5007:6261:6748:7281:9025:9121:10007:10400:10471:10848:11232:11256:11257:11604:11658:11914:12438:12517:12519:12660:13255:13894:13895:21080, 0, RBL:none, CacheIP:none, Bayesian:0.5, 0.5, 0.5, Netcheck:none, DomainCache:0, MSF:not bulk, SPF:fn, MSBL:0, DNSBL:none, Custom_rules:0:1:0 X-HE-Tag: body69_6c977bc965616 X-Filterd-Recvd-Size: 8104 Received: from alvin.alvh.no-ip.org (unknown [181.42.252.223]) (Authenticated sender: alvherre@alvh.no-ip.org) by omf05.b.hostedemail.com (Postfix) with ESMTPA; Tue, 28 Apr 2015 23:12:26 +0000 (UTC) Received: by alvin.alvh.no-ip.org (Postfix, from userid 1000) id 4644B61C; Tue, 28 Apr 2015 20:13:04 -0300 (CLT) Date: Tue, 28 Apr 2015 20:13:04 -0300 From: Alvaro Herrera To: Jeff Janes Cc: Robert Haas , Thomas Munro , Timothy Garnett , Postgres-Bugs , Kevin Grittner Subject: Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Message-ID: <20150428231304.GF4369@alvh.no-ip.org> References: <20150428145614.GA4369@alvh.no-ip.org> <20150428175414.GC4369@alvh.no-ip.org> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="G3juXO9GfR42w+sw" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org --G3juXO9GfR42w+sw Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit Jeff Janes wrote: > Starting with commit b69bf30b9bfacafc733a9ba7 and continuing to this > just-described commit, I can no longer upgrade from a 9.2.10 database using > pg_upgrade. Here's a patch, but I don't like it too much. Will think more about it, probably going to push something tomorrow. -- Álvaro Herrera http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services --G3juXO9GfR42w+sw Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="memberswrap-3.patch" commit b7538e5da55eb8e69021ccb2c7bca0d0019be6c3 Author: Alvaro Herrera Date: Tue Apr 28 19:15:02 2015 -0300 fix boot after pg_upgrade diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c index 06bcd52..6e0e870 100644 --- a/src/backend/access/transam/multixact.c +++ b/src/backend/access/transam/multixact.c @@ -1042,9 +1042,9 @@ GetNewMultiXactId(int nmembers, MultiXactOffset *offset) ExtendMultiXactOffset(result); /* - * Reserve the members space, similarly to above. Also, be careful not to - * return zero as the starting offset for any multixact. See - * GetMultiXactIdMembers() for motivation. + * Compute the members space we need. Be careful not to return zero as the + * starting offset for any multixact. See GetMultiXactIdMembers() for + * motivation. */ nextOffset = MultiXactState->nextOffset; if (nextOffset == 0) @@ -1096,6 +1096,7 @@ GetNewMultiXactId(int nmembers, MultiXactOffset *offset) MultiXactState->offsetStopLimit - nextOffset + nmembers), errhint("Execute a database-wide VACUUM in that database with reduced vacuum_multixact_freeze_min_age and vacuum_multixact_freeze_table_age settings."))); + /* And make sure there is room in the members files */ ExtendMultiXactMember(nextOffset, nmembers); /* @@ -1938,6 +1939,17 @@ MaybeExtendOffsetSlru(void) } LWLockRelease(MultiXactOffsetControlLock); + + /* also create member page 0, also removed by pg_upgrade */ + LWLockAcquire(MultiXactMemberControlLock, LW_EXCLUSIVE); + if (!SimpleLruDoesPhysicalPageExist(MultiXactMemberCtl, 0)) + { + int slotno; + + slotno = ZeroMultiXactMemberPage(0, false); + SimpleLruWritePage(MultiXactMemberCtl, slotno); + } + LWLockRelease(MultiXactMemberControlLock); } /* @@ -1966,12 +1978,6 @@ StartupMultiXact(void) */ pageno = MXOffsetToMemberPage(offset); MultiXactMemberCtl->shared->latest_page_number = pageno; - - /* - * compute the oldest member we need to keep around to avoid old member - * data overrun. - */ - DetermineSafeOldestOffset(MultiXactState->oldestMultiXactId); } /* @@ -2145,7 +2151,8 @@ MultiXactSetNextMXact(MultiXactId nextMulti, * of our cluster), and the OID of the (or a) database with that value. */ void -SetMultiXactIdLimit(MultiXactId oldest_datminmxid, Oid oldest_datoid) +SetMultiXactIdLimit(MultiXactId oldest_datminmxid, Oid oldest_datoid, + bool compute_offset_limit) { MultiXactId multiVacLimit; MultiXactId multiWarnLimit; @@ -2217,7 +2224,8 @@ SetMultiXactIdLimit(MultiXactId oldest_datminmxid, Oid oldest_datoid) curMulti = MultiXactState->nextMXact; LWLockRelease(MultiXactGenLock); - DetermineSafeOldestOffset(oldest_datminmxid); + if (compute_offset_limit) + DetermineSafeOldestOffset(oldest_datminmxid); /* Log the info */ ereport(DEBUG1, @@ -2312,7 +2320,7 @@ void MultiXactAdvanceOldest(MultiXactId oldestMulti, Oid oldestMultiDB) { if (MultiXactIdPrecedes(MultiXactState->oldestMultiXactId, oldestMulti)) - SetMultiXactIdLimit(oldestMulti, oldestMultiDB); + SetMultiXactIdLimit(oldestMulti, oldestMultiDB, true); else DetermineSafeOldestOffset(oldestMulti); } diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index c52f94c..ba2f236 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -4061,7 +4061,7 @@ BootStrapXLOG(void) ShmemVariableCache->oidCount = 0; MultiXactSetNextMXact(checkPoint.nextMulti, checkPoint.nextMultiOffset); SetTransactionIdLimit(checkPoint.oldestXid, checkPoint.oldestXidDB); - SetMultiXactIdLimit(checkPoint.oldestMulti, checkPoint.oldestMultiDB); + SetMultiXactIdLimit(checkPoint.oldestMulti, checkPoint.oldestMultiDB, false); /* Set up the XLOG page header */ page->xlp_magic = XLOG_PAGE_MAGIC; @@ -5290,7 +5290,7 @@ StartupXLOG(void) ShmemVariableCache->oidCount = 0; MultiXactSetNextMXact(checkPoint.nextMulti, checkPoint.nextMultiOffset); SetTransactionIdLimit(checkPoint.oldestXid, checkPoint.oldestXidDB); - SetMultiXactIdLimit(checkPoint.oldestMulti, checkPoint.oldestMultiDB); + SetMultiXactIdLimit(checkPoint.oldestMulti, checkPoint.oldestMultiDB, false); MultiXactSetSafeTruncate(checkPoint.oldestMulti); XLogCtl->ckptXidEpoch = checkPoint.nextXidEpoch; XLogCtl->ckptXid = checkPoint.nextXid; @@ -8133,7 +8133,7 @@ xlog_redo(XLogRecPtr lsn, XLogRecord *record) MultiXactSetNextMXact(checkPoint.nextMulti, checkPoint.nextMultiOffset); SetTransactionIdLimit(checkPoint.oldestXid, checkPoint.oldestXidDB); - SetMultiXactIdLimit(checkPoint.oldestMulti, checkPoint.oldestMultiDB); + SetMultiXactIdLimit(checkPoint.oldestMulti, checkPoint.oldestMultiDB, true); MultiXactSetSafeTruncate(checkPoint.oldestMulti); /* diff --git a/src/backend/commands/vacuum.c b/src/backend/commands/vacuum.c index ba3fbbd..746a093 100644 --- a/src/backend/commands/vacuum.c +++ b/src/backend/commands/vacuum.c @@ -1093,7 +1093,7 @@ vac_truncate_clog(TransactionId frozenXID, * signalling twice? */ SetTransactionIdLimit(frozenXID, oldestxid_datoid); - SetMultiXactIdLimit(minMulti, minmulti_datoid); + SetMultiXactIdLimit(minMulti, minmulti_datoid, true); } diff --git a/src/include/access/multixact.h b/src/include/access/multixact.h index e69a3d2..3ad8d16 100644 --- a/src/include/access/multixact.h +++ b/src/include/access/multixact.h @@ -111,7 +111,7 @@ extern void StartupMultiXact(void); extern void TrimMultiXact(void); extern void ShutdownMultiXact(void); extern void SetMultiXactIdLimit(MultiXactId oldest_datminmxid, - Oid oldest_datoid); + Oid oldest_datoid, bool compute_offset_limit); extern void MultiXactGetCheckptMulti(bool is_shutdown, MultiXactId *nextMulti, MultiXactOffset *nextMultiOffset, --G3juXO9GfR42w+sw Content-Type: text/plain Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs --G3juXO9GfR42w+sw--