Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VytqI-0001AD-Mw for pgsql-bugs@arkaria.postgresql.org; Fri, 03 Jan 2014 01:46:30 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1VytqI-0007SG-5K for pgsql-bugs@arkaria.postgresql.org; Fri, 03 Jan 2014 01:46:30 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VytqH-0007SA-DM for pgsql-bugs@postgresql.org; Fri, 03 Jan 2014 01:46:29 +0000 Received: from smtprelay0113.b.hostedemail.com ([64.98.42.113] helo=smtprelay.b.hostedemail.com) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Vytq9-00031g-KN for pgsql-bugs@postgresql.org; Fri, 03 Jan 2014 01:46:28 +0000 Received: from filter.hostedemail.com (b-bigip1 [10.5.19.254]) by smtprelay01.b.hostedemail.com (Postfix) with ESMTP id BBE642D2B6D; Fri, 3 Jan 2014 01:46:20 +0000 (UTC) X-Session-Marker: 616C76686572726540616C76682E6E6F2D69702E6F7267 X-Spam-Summary: 13, 1.2, 0, , d41d8cd98f00b204, alvherre@alvh.no-ip.org, :::::, RULES_HIT:41:355:379: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:2196:2197:2198:2199:2200:2201:2393:2525:2553:2560:2563:2682:2685:2736: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:4321:4385:4560:4605:4659:5007:6117:6261:7875:7903:8526:9025:9121:10008:10400:10483:10848:10967:11026:11232:11256:11257:11473:11658:11914:12043:12049:12438:12517:12519:12555:12663:12740:13161:13229:13255:13894:13895:19901:19997, 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: hour92_544a5e2f5e345 X-Filterd-Recvd-Size: 4826 Received: from eldon.alvh.no-ip.org (pc-211-245-160-190.cm.vtr.net [190.160.245.211]) (Authenticated sender: alvherre@alvh.no-ip.org) by omf11.b.hostedemail.com (Postfix) with ESMTPA; Fri, 3 Jan 2014 01:46:19 +0000 (UTC) Received: by eldon.alvh.no-ip.org (Postfix, from userid 1000) id 6801F1FC9; Thu, 2 Jan 2014 22:46:17 -0300 (CLST) Date: Thu, 2 Jan 2014 22:46:17 -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: <20140103014616.GB7035@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: > 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 > > 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. > > 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. I have applied three patches to deal with some of the problems reported here, and others discovered during the investigation of them. One of them was about failing to truncate files beyond FFFF. That should work fine now -- that is, you would lose more data. Unless we consider a second fix, which is that files corresponding to data still in use are no longer truncated. I had to include the third fix (to enable the system to wrap around sanely from file 14078 to 0000) was necessary so I could reproduce the issues. In systems with assertions enabled, there is a crash at the point of overflow. I didn't try, but since your system appears to have wrapped around I imagine it sort-of works in systems compiled without assertions (which is the recommended setting for production settings.) One thing not yet patched is overrun of members' SLRU: if you have enough live multixacts with enough members, creating a new one might overwrite the members area used by an older member. Freezing multis earlier would help with that. With the default settings, where multis are frozen when they are 50 million multis old and pages are 8kB long, there is room for 85 members per multi on average without such overrun[*]. I was able to observe this overrun by running Andres' pg_multixact_burn with each multixact having 100 members. I doubt it's common to have that many members in each multixact on average, but it's certainly a possibility. [*] There are 82040 files, having 32 pages each; each page has room for 1636 members. (82040 * 32 / 1636) / 50000000 =~ 85. One complaint somebody might rightly have about this is the space consumption by pg_multixact/ files. Perhaps instead of using Xid's freezing horizon verbatim, we should use ceil(min_freeze_age^0.8) or something like that; so for the default 50000000 Xid freezing age, we would freeze multis over 1.44 million multis old. (We could determine ratio of xid to multi usage so that they would both freeze when the same time has lapsed, but this seems unnecessarily complicated.) -- Á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