Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WsFPX-0005zV-WA for pgsql-bugs@arkaria.postgresql.org; Wed, 04 Jun 2014 17:55:40 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1WsFPX-0000hC-FJ for pgsql-bugs@arkaria.postgresql.org; Wed, 04 Jun 2014 17:55:39 +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 1WsFPW-0000h6-Q6 for pgsql-bugs@postgresql.org; Wed, 04 Jun 2014 17:55:38 +0000 Received: from smtprelay0085.b.hostedemail.com ([64.98.42.85] helo=smtprelay.b.hostedemail.com) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WsFPR-0002zd-Ok for pgsql-bugs@postgresql.org; Wed, 04 Jun 2014 17:55:37 +0000 Received: from filter.hostedemail.com (b-bigip1 [10.5.19.254]) by smtprelay06.b.hostedemail.com (Postfix) with ESMTP id B07208D016; Wed, 4 Jun 2014 17:55:31 +0000 (UTC) X-Session-Marker: 616C76686572726540616C76682E6E6F2D69702E6F7267 X-Spam-Summary: 50, 0, 0, , d41d8cd98f00b204, alvherre@alvh.no-ip.org, :::, RULES_HIT:41:355:379:599:800:871:960:967:973:988:989:1028:1260:1311:1312:1313:1314:1345:1359:1431:1437:1515:1516:1518:1519:1535:1543:1575:1594:1595:1596:1605:1711:1730:1747:1764:1777:1792:2393:2525:2560:2563:2682:2685:2692:2743:2859:2895:2919:2933:2937:2939:2942:2945:2947:2951:2954:3022:3138:3139:3140:3141:3142:3865:3866:3867:3868:3870:3871:3872:3873:3874:3934:3936:3938:3941:3944:3947:3950:3953:3956:3959:4250:4321:4605:4659:5007:6119:6261:6996:6997:7281:7809:7903:7909:9025:9121:10004:10400:10848:11232:11256:11257:11473:11658:11914:12296:12517:12519:12555:12660:12663:12740:13161:13229:13255:13894:13895:21063, 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:0:0 X-HE-Tag: force62_4d3e76c60ec59 X-Filterd-Recvd-Size: 5916 Received: from eldon.alvh.no-ip.org (unknown [186.11.239.38]) (Authenticated sender: alvherre@alvh.no-ip.org) by omf06.b.hostedemail.com (Postfix) with ESMTPA; Wed, 4 Jun 2014 17:55:30 +0000 (UTC) Received: by eldon.alvh.no-ip.org (Postfix, from userid 1000) id 415751FD2; Wed, 4 Jun 2014 13:46:59 -0400 (CLT) Date: Wed, 4 Jun 2014 13:46:59 -0400 From: Alvaro Herrera To: Serge Negodyuck Cc: pgsql-bugs@postgresql.org Subject: Re: BUG #8673: Could not open file "pg_multixact/members/xxxx" on slave during hot_standby Message-ID: <20140604174659.GP5146@eldon.alvh.no-ip.org> References: <20131209142525.GA1123@awork2.anarazel.de> <20131209150345.GB1123@awork2.anarazel.de> <20131209182701.GD9519@awork2.anarazel.de> <20140103014616.GB7035@eldon.alvh.no-ip.org> <20140602141041.GS7857@eldon.alvh.no-ip.org> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="vkogqOf2sHV7VnPd" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: 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 --vkogqOf2sHV7VnPd Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit Serge Negodyuck wrote: > 2014-06-02 17:10 GMT+03:00 Alvaro Herrera : > > > Serge Negodyuck wrote: > > > Hello, > > > > > > I've upgraded postgresql to version 9.3.4 and did fresh initdb and > > restored > > > database from sql backup. > > > According to 9.4.3 changelog issue with multixact wraparound was fixed. > > > > Ouch. This is rather strange. First I see the failing multixact has > > 8684 members, which is totally unusual. My guess is that you have code > > that creates lots of subtransactions, and perhaps does something to one > > tuple in a different subtransaction; doing sometihng like that would be, > > I think, the only way to get subxacts that large. Does that sound > > right? > > > It sounds like you are right. I've found a lot of inserts in logs. Each > insert cause trigger to be performed. This trigger updates counter in > other table. > It is very possible this tirgger tries to update the same counter for > different inserts. I wasn't able to reproduce it that way, but I eventually figured out that if I altered altered the plpython function to grab a FOR NO KEY UPDATE lock first, insertion would grow the multixact beyond reasonable limits; see the attachment. If you then INSERT many tuples in "product" in a single transaction, the resulting xmax is a Multixact that has as many members as inserts there are, plus one. (One variation that causes even more bizarre results is dispensing with the plpy.subtransaction() in the function and instead setting a savepoint before each insert. In fact, given the multixact members shown in your log snippet I think that's more similar to what you code does.) > > > Then, did pg_basebackup to slave database. It does not help > > > 2014-06-02 09:58:49 EEST 172.18.10.17 db2 DETAIL: Could not open file > > > "pg_multixact/members/1112D": No such file or directory. > > > 2014-06-02 09:58:49 EEST 172.18.10.18 db2 DETAIL: Could not open file > > > "pg_multixact/members/11130": No such file or directory. > > > 2014-06-02 09:58:51 EEST 172.18.10.34 db2 DETAIL: Could not open file > > > "pg_multixact/members/11145": No such file or directory. > > > 2014-06-02 09:58:51 EEST 172.18.10.38 db2 DETAIL: Could not open file > > > "pg_multixact/members/13F76": No such file or directory > > > > Are these the only files missing? Are intermediate files there? > > Only 0000 - 001E files were present on slave server. I don't understand how can files be missing in the replica. pg_basebackup simply copies all files it can find in the master to the replica, so if the 111xx files are present in the master they should certainly be present in the replica as well. I gave the pg_basebackup code a look just to be sure there are no 4-char pattern matching or something like that, and it doesn't look like it attempts to do that at all. I also asked Magnus just to be sure and he confirms this. I'm playing a bit more with this test case, I'll let you know where it leads. -- Álvaro Herrera http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Training & Services --vkogqOf2sHV7VnPd Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=init drop table if exists company, product; CREATE TABLE company ( id integer primary key, name text, num_products integer ); CREATE TABLE product ( id serial primary key, company_id integer not null references company); CREATE or replace FUNCTION update_num_products() RETURNS trigger LANGUAGE plpythonu AS $$ new = TD["new"] def lock_company(company_id): plpy.execute(""" SELECT * FROM company WHERE id = %(company_id)s FOR NO KEY UPDATE """ % {'company_id': company_id}) def update_company(company_id, delta): plpy.execute(""" UPDATE company SET num_products = coalesce(num_products, 0) + %(delta)s WHERE id = %(company_id)s """ % {'company_id': company_id, 'delta': delta}) with plpy.subtransaction(): # lock_company(new['company_id']) update_company(new['company_id'], 1) $$; CREATE TRIGGER update_num_products AFTER INSERT OR UPDATE ON product FOR EACH ROW EXECUTE PROCEDURE update_num_products(); INSERT into company VALUES (0,1); --vkogqOf2sHV7VnPd 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 --vkogqOf2sHV7VnPd--