Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1X01Z3-0001za-Oj for pgsql-hackers@arkaria.postgresql.org; Thu, 26 Jun 2014 04:45:37 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1X01Z2-0005Fc-Tx for pgsql-hackers@arkaria.postgresql.org; Thu, 26 Jun 2014 04:45: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 1X01Z0-0005FQ-93 for pgsql-hackers@postgresql.org; Thu, 26 Jun 2014 04:45:34 +0000 Received: from smtprelay0203.b.hostedemail.com ([64.98.42.203] helo=smtprelay.b.hostedemail.com) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1X01Yq-0000Oe-7i for pgsql-hackers@postgresql.org; Thu, 26 Jun 2014 04:45:32 +0000 Received: from filter.hostedemail.com (b-bigip1 [10.5.19.254]) by smtprelay05.b.hostedemail.com (Postfix) with ESMTP id 246B532AEF1; Thu, 26 Jun 2014 04:45:22 +0000 (UTC) X-Session-Marker: 616C76686572726540616C76682E6E6F2D69702E6F7267 X-Spam-Summary: 20, 1.5, 0, , d41d8cd98f00b204, alvherre@alvh.no-ip.org, :::::, RULES_HIT:41:355:379:599:940:967:968:973:988:989:1260:1277:1311:1312:1313:1314:1345:1359:1437:1515:1516:1518:1519:1534:1542:1593:1594:1595:1596:1711:1730:1747:1777:1792:2194:2198:2199:2200:2393:2525:2560:2563:2682:2685:2689:2828:2859:2895:2904:2933:2937:2939:2942:2945:2947:2951:2954:3022:3138:3139:3140:3141:3142:3355:3865:3866:3867:3868:3870:3871:3872:3874:3934:3936:3938:3941:3944:3947:3950:3953:3956:3959:4031:4250:4321:4605:4659:5007:6119:6261:7903:8660:8957:9025:9121:10009:10400:10471:10848:10967:11026:11232:11256:11257:11658:11876:11914:12043:12050:12296:12438:12517:12519:12740:13053:13148:13149:13230:13255:13548:13894:13895:13972:21063: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:2:0 X-HE-Tag: yard04_8619f32692f42 X-Filterd-Recvd-Size: 4346 Received: from eldon.alvh.no-ip.org (pc-65-79-161-190.cm.vtr.net [190.161.79.65]) (Authenticated sender: alvherre@alvh.no-ip.org) by omf06.b.hostedemail.com (Postfix) with ESMTPA; Thu, 26 Jun 2014 04:45:21 +0000 (UTC) Received: by eldon.alvh.no-ip.org (Postfix, from userid 1000) id EE4391FCB; Thu, 26 Jun 2014 00:45:19 -0400 (CLT) Date: Thu, 26 Jun 2014 00:45:19 -0400 From: Alvaro Herrera To: Andres Freund Cc: Jeff Janes , pgsql-hackers Subject: Re: Re: [BUGS] BUG #8673: Could not open file "pg_multixact/members/xxxx" on slave during hot_standby Message-ID: <20140626044519.GJ7340@eldon.alvh.no-ip.org> References: <20131209182701.GD9519@awork2.anarazel.de> <20140103014616.GB7035@eldon.alvh.no-ip.org> <20140606013943.GT5146@eldon.alvh.no-ip.org> <20140606164727.GU5146@eldon.alvh.no-ip.org> <20140609225039.GC18688@eldon.alvh.no-ip.org> <20140620213816.GB1795@eldon.alvh.no-ip.org> <20140620223810.GH30721@alap3.anarazel.de> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20140620223810.GH30721@alap3.anarazel.de> User-Agent: Mutt/1.5.21 (2010-09-15) X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org Andres Freund wrote: > On 2014-06-20 17:38:16 -0400, Alvaro Herrera wrote: > > It seems to me that we need to keep the offsets files around until a > > checkpoint has written the "oldest" number to WAL. In other words we > > need additional state in shared memory: (a) what we currently store > > which is the oldest number as computed by vacuum (not safe to delete, > > but it's the number that the next checkpoint must write), and (b) the > > oldest number that the last checkpoint wrote (the safe deletion point). > > Why not just WAL log truncations? If we'd emit the WAL record after > determining the offsets page we should be safe I think? That seems like > easier and more robust fix? And it's what e.g. the clog does. Yes, I think this whole thing would be simpler if we just wal-logged the truncations, like pg_clog does. But I would like to avoid doing that for now, and do it in 9.5 only in the future. As a backpatchable (to 9.4/9.3) fix, I propose we do the following: 1. have vacuum update MultiXactState->oldestMultiXactId based on the minimum value of pg_database->datminmxid. Since this value is saved in pg_control, it is restored from checkpoint replay during recovery. 2. Keep track of a new value, MultiXactState->lastCheckpointedOldest. This value is updated by CreateCheckPoint in a primary server after the checkpoint record has been flushed, and by xlog_redo in a hot standby, to be the MultiXactState->oldestMultiXactId value that was last flushed. 3. TruncateMultiXact() no longer receives a parameter. Files are removed based on MultiXactState->lastCheckpointedOldest instead. 4. call TruncateMultiXact at checkpoint time, after the checkpoint WAL record has been flushed, and at restartpoint time (just like today). This means we only remove files that a prior checkpoint has already registered as being no longer necessary. Also, if a recovery is interrupted before end of WAL (recovery target), the files are still present. So we no longer truncate during vacuum. Another consideration for (4) is that right now we're only invoking multixact truncation in a primary when we're able to advance pg_database.datminmxid (see vac_update_datfrozenxid). The problem is that after a crash and subsequent recovery, pg_database might be updated without removing pg_multixact files; this would mean that the next opportunity to remove files would be far in the future, when the minimum datminmxid is advanced again. One way to fix that would be to have every single call to vac_update_datfrozenxid() attempt multixact truncation, but that seems wasteful since I expect vacuuming is more frequent than checkpointing. -- Álvaro Herrera http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Training & Services -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers