Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Vq64O-0008Av-6l for pgsql-bugs@arkaria.postgresql.org; Mon, 09 Dec 2013 19:00:40 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1Vq64N-0002EC-Jq for pgsql-bugs@arkaria.postgresql.org; Mon, 09 Dec 2013 19:00:39 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Vq64M-0002Ck-HG for pgsql-bugs@postgresql.org; Mon, 09 Dec 2013 19:00:38 +0000 Received: from smtprelay0112.b.hostedemail.com ([64.98.42.112] helo=smtprelay.b.hostedemail.com) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Vq64J-0005Rt-5S for pgsql-bugs@postgresql.org; Mon, 09 Dec 2013 19:00:37 +0000 Received: from filter.hostedemail.com (b-bigip1 [10.5.19.254]) by smtprelay02.b.hostedemail.com (Postfix) with ESMTP id 6894ED3982; Mon, 9 Dec 2013 19:00:34 +0000 (UTC) X-Session-Marker: 616C76686572726540616C76682E6E6F2D69702E6F7267 X-Spam-Summary: 13, 1.2, 0, , d41d8cd98f00b204, alvherre@alvh.no-ip.org, :::::, RULES_HIT:41:355:379:421:599:960:966:967:968:973:988:989:1260:1277:1311:1312:1313:1314:1345:1359:1437:1515:1516:1518:1519:1534:1543:1593:1594:1595:1596:1605:1711:1730:1747:1777:1792:2195:2196:2197:2198:2199:2200:2201:2202:2393:2525:2553:2560:2563:2682:2685:2693:2828:2859:2933:2937:2939:2942:2945:2947:2951:2954:3022:3138:3139:3140:3141:3142:3834:3865:3866:3867:3868:3870:3871:3872:3873:3874:3934:3936:3938:3941:3944:3947:3950:3953:3956:3959:4184:4321:4385:4560:4605:4659:5007:6117:6261:7875:7903:7974:8957:9025:9121:10008:10400:10848:10967:11026:11232:11256:11257:11473:11658:11914:12043:12049:12296:12438:12517:12519:12555:12663:12740:13149:13230:13255:13894:13895:21060, 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: cause08_5c0f09644b042 X-Filterd-Recvd-Size: 4310 Received: from eldon.alvh.no-ip.org (pc-223-216-160-190.cm.vtr.net [190.160.216.223]) (Authenticated sender: alvherre@alvh.no-ip.org) by omf11.b.hostedemail.com (Postfix) with ESMTPA; Mon, 9 Dec 2013 19:00:32 +0000 (UTC) Received: by eldon.alvh.no-ip.org (Postfix, from userid 1000) id 25F221FC8; Mon, 9 Dec 2013 16:00:32 -0300 (CLST) Date: Mon, 9 Dec 2013 16:00:32 -0300 From: Alvaro Herrera To: Andres Freund Cc: Serge Negodyuck , pgsql-bugs@postgresql.org Subject: Re: BUG #8673: Could not open file "pg_multixact/members/xxxx" on slave during hot_standby Message-ID: <20131209190031.GK6777@eldon.alvh.no-ip.org> References: <20131209142525.GA1123@awork2.anarazel.de> <20131209150345.GB1123@awork2.anarazel.de> <20131209182701.GD9519@awork2.anarazel.de> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20131209182701.GD9519@awork2.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-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org Andres Freund wrote: > Hi, > > On 2013-12-09 17:49:34 +0200, Serge Negodyuck wrote: > > On master there are files from 0000 to 14078 > > > > On slave there were absent files from A1xx to FFFF > > They were the oldest ones. (October, November) > > Some analysis later, I am pretty sure that the origin is a longstanding > problem and not connected to 9.3.[01] vs 9.3.2. > > The above referenced 14078 file is exactly the last page before a > members wraparound: > (gdb) p/x (1L<<32)/(MULTIXACT_MEMBERS_PER_PAGE * SLRU_PAGES_PER_SEGMENT) > $10 = 0x14078 As a note, the SlruScanDirectory code has a flaw because it only looks at four-digit files; the reason only files up to 0xFFFF are missing and not the following ones is because those got ignored. This needs a fix as well. > So, what happened is that enough multixacts where created, that the > members slru wrapped around. It's not unreasonable for the members slru > to wrap around faster then the offsets one - after all we create at > least two entries into members for every offset entry. Also in 9.3+ > there fit more xids on a offset than a members page. > When truncating, we first read the offset, to know where we currently > are in members, and then truncate both from their respective > point. Since we've wrapped around in members we very well might remove > content we actually need. Yeah, on 9.3 each member Xid occupies five bytes in pg_multixact/members, whereas each offset only occupies four bytes in pg_multixact/offsets. It's rare that a multixact only contains one member; typically they will have at least two (so for each multixact we would have 4 bytes in offsets and a minimum of 10 bytes in members). So wrapping around is easy for members, even with the protections we have in place for offsets. > I've recently remarked that I find it dangerous that we only do > anti-wraparound stuff for pg_multixact/offsets, not for /members. So, > here we have the proof that that's bad. It's hard to see how to add this post-facto, though. I mean, I am thinking we would need some additional pg_control info etc. We'd better figure out a way to add such controls without having to add that. > This is an issue in <9.3 as well. It might, in some sense, even be worse > there, because we never vacuum old multis away. But on the other hand, > the growths of multis is slower there and we look into old multis less > frequently. > > The only reason that you saw the issue on the standby first is that the > truncation code is called more frequently there. Afaics it will happen, > sometime in the future, on the master as well. > > I think problems should be preventable if you issue a systemwide VACUUM > FREEZE, but please let others chime in before you execute it. I wouldn't freeze anything just yet, at least until the patch to fix multixact freezing is in. -- Álvaro Herrera http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Training & Services -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs