pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Brian Ghidinelli <brian@vfive.com>
To: pgsql-bugs@postgresql.org
Cc: Alvaro Herrera <alvherre@alvh.no-ip.org>
Subject: Re: BUG #13970: Vacuum hangs on particular table; cannot be terminated - requires `kill -QUIT pid` [WORKAROUND]
Date: Wed, 24 Feb 2016 23:21:30 -0800
Message-ID: <947F2124-FEEA-4208-828F-515C7EA7951A@vfive.com> (raw)
In-Reply-To: <20160219214155.GA149963@alvherre.pgsql>
References: <20160219214155.GA149963@alvherre.pgsql>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>


> On Feb 19, 2016, at 13:41, Alvaro Herrera <alvherre@alvh.no-ip.org> wrote:
> 
> Brian Ghidinelli wrote:
>> 
>> Thanks Alvaro - both for the help and the reco. I’m pretty technical
>> but it definitely makes me nervous to start mucking around at that
>> level. 
>> 
>> Is there any chance that a tool like pg_repack or similar would fix
>> this? Or recreating the table and reattaching all of the foreign keys?
>> Wondering if there is a “safer” approach to achieve the same result?
> 
> Yeah, that would work because if you drop the table, the Xmax values are
> all gone.

A follow-up here - I manually VACUUM’d the 106 other tables in my database to isolate that only my ClubMember table was having this Xid issue. With that confirmed, I scripted a replacement for the table like:

DROP TABLE IF EXISTS ClubMemberNew;
CREATE TABLE ClubMemberNew (LIKE ClubMember INCLUDING ALL) WITHOUT OIDS;
INSERT INTO ClubMemberNew SELECT * FROM ClubMember;

And then restored the 5 FKs on this table like:

ALTER TABLE ClubMemberNew
  ADD CONSTRAINT clubmember_club_fkey FOREIGN KEY (uidclub)
      REFERENCES club (uidclub) MATCH SIMPLE ON UPDATE CASCADE ON DELETE CASCADE;

And then migrated 16 FKs pointing to the ClubMember table like:

ALTER TABLE Credit DROP CONSTRAINT credit_clubmember_fkey,
  ADD CONSTRAINT credit_clubmember_fkey FOREIGN KEY (uidClubMember) REFERENCES ClubMemberNew (uidClubMember) ON UPDATE CASCADE ON DELETE CASCADE;

And then switched the names and analyzed:

ALTER TABLE ClubMember RENAME TO ClubMemberOld;
ALTER TABLE ClubMemberNew RENAME TO ClubMember;
ANALYZE VERBOSE ClubMember;

I can now successfully VACUUM the new ClubMember table. At the moment, pg_controldata still reports oldestMultiXid = 1. I presume/hope once I drop ClubMemberOld, that will get updated? 

Thanks for all the help!


Brian

view thread (12+ messages)  latest in thread

Message-ID: <947F2124-FEEA-4208-828F-515C7EA7951A@vfive.com>
Permalink:  ../947F2124-FEEA-4208-828F-515C7EA7951A@vfive.com/
Also on:    postgresql.org/message-id/947F2124-FEEA-4208-828F-515C7EA7951A@vfive.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: brian@vfive.com, alvherre@alvh.no-ip.org
  Subject: Re: BUG #13970: Vacuum hangs on particular table; cannot be terminated - requires `kill -QUIT pid` [WORKAROUND]
  In-Reply-To: <947F2124-FEEA-4208-828F-515C7EA7951A@vfive.com>
  References: <20160219214155.GA149963@alvherre.pgsql> <947F2124-FEEA-4208-828F-515C7EA7951A@vfive.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox