Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1aYqFh-0004yL-JW for pgsql-bugs@arkaria.postgresql.org; Thu, 25 Feb 2016 07:22:22 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1aYqFh-00084O-2B for pgsql-bugs@arkaria.postgresql.org; Thu, 25 Feb 2016 07:22:21 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1aYqF3-0007Nl-Pn for pgsql-bugs@postgresql.org; Thu, 25 Feb 2016 07:21:41 +0000 Received: from mail.pukkasoft.com ([69.36.240.122]) by makus.postgresql.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84) (envelope-from ) id 1aYqEw-0007sx-4S for pgsql-bugs@postgresql.org; Thu, 25 Feb 2016 07:21:40 +0000 DKIM-Signature: v=1; a=rsa-sha1; c=simple; d=vfive.com; h=content-type :mime-version:subject:from:in-reply-to:date:cc:message-id :references:to; s=dkim2; bh=nr4iN0faRyNhKkN8Nk1A/OSGEFY=; b=bP50 g1ZNazetdOvDt+AzKJWbfmpxVsR6nk3nvRxCa0YPAcYkrhyYCv/CyLgY3YiouGF/ /kMlv3X2l3/SQi8oXaaqT8mOfLye4HoT4gomfgMbvdD1t9oZC+gKKigOOksqjAUS iGq917aXIsPOFH4eaHWq20Fyj5lMxnhGx38IYpc= Received: (qmail 25149 invoked by uid 89); 25 Feb 2016 07:21:31 -0000 Received: by simscan 1.4.0 ppid: 25140, pid: 25145, t: 0.0783s scanners: attach: 1.4.0 clamav: 0.97/m:54/d:13825 Received: from unknown (HELO ?10.0.0.12?) (brian%pukkasoft.com@50.131.178.106) by mail with ESMTPA; 25 Feb 2016 07:21:31 -0000 Content-Type: multipart/alternative; boundary="Apple-Mail=_8FAFFF60-81B0-4DD9-B922-853A53441483" Mime-Version: 1.0 (Mac OS X Mail 9.2 \(3112\)) Subject: Re: BUG #13970: Vacuum hangs on particular table; cannot be terminated - requires `kill -QUIT pid` [WORKAROUND] From: Brian Ghidinelli In-Reply-To: <20160219214155.GA149963@alvherre.pgsql> Date: Wed, 24 Feb 2016 23:21:30 -0800 Cc: Alvaro Herrera Message-Id: <947F2124-FEEA-4208-828F-515C7EA7951A@vfive.com> References: <20160219214155.GA149963@alvherre.pgsql> To: pgsql-bugs@postgresql.org X-Mailer: Apple Mail (2.3112) X-Pg-Spam-Score: -0.4 (/) 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 --Apple-Mail=_8FAFFF60-81B0-4DD9-B922-853A53441483 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > On Feb 19, 2016, at 13:41, Alvaro Herrera = wrote: >=20 > Brian Ghidinelli wrote: >>=20 >> Thanks Alvaro - both for the help and the reco. I=E2=80=99m pretty = technical >> but it definitely makes me nervous to start mucking around at that >> level.=20 >>=20 >> 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 =E2=80=9Csafer=E2=80=9D approach to achieve = the same result? >=20 > Yeah, that would work because if you drop the table, the Xmax values = are > all gone. A follow-up here - I manually VACUUM=E2=80=99d 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 =3D 1. I presume/hope once I = drop ClubMemberOld, that will get updated?=20 Thanks for all the help! Brian --Apple-Mail=_8FAFFF60-81B0-4DD9-B922-853A53441483 Content-Transfer-Encoding: 7bit Content-Type: text/html; charset=us-ascii
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


--Apple-Mail=_8FAFFF60-81B0-4DD9-B922-853A53441483--