Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cbTN1-0001Xp-TS for pgsql-admin@arkaria.postgresql.org; Wed, 08 Feb 2017 14:37:20 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1cbTN1-0002EO-Gc for pgsql-admin@arkaria.postgresql.org; Wed, 08 Feb 2017 14:37:19 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1cbTN0-0002D4-NS for pgsql-admin@postgresql.org; Wed, 08 Feb 2017 14:37:18 +0000 Received: from mail-by2nam03on0100.outbound.protection.outlook.com ([104.47.42.100] helo=NAM03-BY2-obe.outbound.protection.outlook.com) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1cbTMv-00076a-6l for pgsql-admin@postgresql.org; Wed, 08 Feb 2017 14:37:18 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=weatheranalytics.onmicrosoft.com; s=selector1-weatheranalytics-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=dT1KCrNAhkFMK5hcCSd/6rgLE5DSh57NX3n7cwM0Z/8=; b=Qk+M02Sbxr3a+NCcfZa4UuRmXRN0f1z3u+QrB/pI264LSZXpswJ+X8p4z7xIYQj5HGd6lJ5JmoCBadxZTI2da6XTTa6cdj7FjZ0VuZO1ZZpxONewrrUpE8xHoRuSItVI0Hi4OaQnTZQyLgTNVAYRm453Pw32eRXxeRX3XZfVTZ4= Received: from DM5PR07MB2747.namprd07.prod.outlook.com (10.168.104.139) by DM5PR07MB2747.namprd07.prod.outlook.com (10.168.104.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.860.13; Wed, 8 Feb 2017 14:37:08 +0000 Received: from DM5PR07MB2747.namprd07.prod.outlook.com ([10.168.104.139]) by DM5PR07MB2747.namprd07.prod.outlook.com ([10.168.104.139]) with mapi id 15.01.0860.026; Wed, 8 Feb 2017 14:37:08 +0000 From: Ganesh Kannan To: "pgsql-admin@postgresql.org" Subject: Re: Recovery from Transaction wraparound failure Thread-Topic: Recovery from Transaction wraparound failure Thread-Index: AQHSgdN5XhyNAhTqF0a8rTaUGF0coqFfJ4T7 Date: Wed, 8 Feb 2017 14:37:08 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=ganesh.kannan@weatheranalytics.com; x-originating-ip: [25.168.111.132] x-ms-office365-filtering-correlation-id: 94da7b16-ba1c-4c0a-3111-08d4502ff629 x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001);SRVR:DM5PR07MB2747; x-microsoft-exchange-diagnostics: 1;DM5PR07MB2747;7:E+4p8Ipm51vezqQXZFYmKxKbLd1TdcLgiifSaLRsq5Av3op/Ea8kU424Anof1pdxoeaMOWa8PZlAeMnPFeeN/847Kk95LlHSys1PVHdJWSNLxWCg34wjMaz7bqksi31mgv4qEgkOI570HsotEsEHxNvnZzv2hUKn7s5nkUZc434Uq2eWsqlh7JHIUqIGrSuYug6TW2dakbjB0KUGWXivUfNQdx6s5QeV+beBYLFO0CSTWT5g3Vttb8YeUd99ra3o6MMZ/lxzpj16RxwOMd4YyVQ1iHcBdFiYS2WNSSplPwhkgZtRnH//J4qPJw0gT0wFtt5ZEAse7b0Z2s6RX9dxEmh+MicKH3N27glazQvwzQelUJlENy6N4Bqun3iiN34vzQvZe7Bj9Rzw81DhsW0E2oobRF5nwt4fTIX9FvfW1vOVnq6CWn0ERBwjygs1dZbSwxn5MU9T0g/NvMJj5QIke6GcpV7VxraljYbSIW/2641ARl1W/7L8ODJhW5JX/dVV9bjAavy2Dq+T3/VfRr4B7w== x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(158342451672863); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(6040375)(601004)(2401047)(8121501046)(20170203043)(2017020702029)(5005006)(3002001)(10201501046)(6041248)(20161123562025)(2016111802025)(20161123560025)(20161123555025)(20161123564025)(20161123558025)(6043046)(6072148);SRVR:DM5PR07MB2747;BCL:0;PCL:0;RULEID:;SRVR:DM5PR07MB2747; x-forefront-prvs: 0212BDE3BE x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(6009001)(7916002)(39450400003)(39830400002)(39410400002)(40764003)(377454003)(199003)(43784003)(189002)(377424004)(53754006)(2950100002)(3660700001)(450100001)(81166006)(38730400002)(551934003)(122556002)(9686003)(8676002)(6436002)(77096006)(2900100001)(8936002)(7736002)(106116001)(106356001)(3846002)(189998001)(6506006)(102836003)(92566002)(6116002)(53546003)(2351001)(74316002)(66066001)(19627405001)(2906002)(6246003)(99286003)(6916009)(68736007)(53936002)(97736004)(81156014)(101416001)(55016002)(5660300001)(25786008)(2501003)(6606003)(105586002)(54896002)(5640700003)(76176999)(229853002)(3280700002)(110136004)(33656002)(54356999)(50986999)(86362001)(7696004);DIR:OUT;SFP:1102;SCL:1;SRVR:DM5PR07MB2747;H:DM5PR07MB2747.namprd07.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; received-spf: None (protection.outlook.com: weatheranalytics.com does not designate permitted sender hosts) spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: multipart/alternative; boundary="_000_DM5PR07MB2747653DAC96763C3B4F785A86420DM5PR07MB2747namp_" MIME-Version: 1.0 X-OriginatorOrg: weatheranalytics.com X-MS-Exchange-CrossTenant-originalarrivaltime: 08 Feb 2017 14:37:08.6799 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 7c8e281f-8a72-4b26-8eba-1efcdf986ddb X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR07MB2747 X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-admin Precedence: bulk Sender: pgsql-admin-owner@postgresql.org --_000_DM5PR07MB2747653DAC96763C3B4F785A86420DM5PR07MB2747namp_ Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Update... I let the vacuum db for the night and i see there are about 10 tables that = were never vacuumed (reduced from 20 tables.) select t.relname, t.last_vacuum, t.last_autovacuum, c.relfrozenxid, age(c.r= elfrozenxid) from pg_stat_user_tables t, pg_class c where schemaname=3D'weather_data' and c.relkind=3D'r' and t.relid=3Dc.oid and last_vacuum is null and last_autovacuum is null order by last_vacuum desc, last_autovacuum desc; Adding that there are more than 1000 tables (each 14 GB or so) that match a= ge(relfrozenxid) > I could again take the database into single-user mode and let it run, but n= ot sure if vacuum would get to those 10 tables first or not. can someone sh= ed some light on the order in which manual vacuum or auto vacuum would pick= up tables for vacuum? Regarding running the postgres --single in background, I used disown to let= it run through overnight, but I had to kill the process to open the DB for= read-only sessions. When i checked the pg_class.last_vacuum field, I don't= see any table was vacuumed though the process was running for 8 hours. Doe= s killing the single user mode affect "vacuum" from registering the fact it= did vacuum on tables? Thanks again, and I hope that there is enough intrigue and information here= to get someone willing to help me out. Ganesh ________________________________ From: Ganesh Kannan Sent: Wednesday, February 8, 2017 1:48:10 AM To: pgsql-admin@postgresql.org Subject: Recovery from Transaction wraparound failure Hi All, One of the production databases that we own is having transactions wraparou= nd issue. This is a large database with more than 2000 tables, 70TB in size= . Most of the tables run between 14 to 20GB in size. This database is predo= minantly read-only work load, but gets millions of new rows each day in bat= ches. There are about 20 tables that were never vacuumed manually or picked= up by auto vacuum, and I suspect those may be the ones causing the issue. At first, I started seeing this error for all writes: sqlerrm:database is not accepting commands to avoid wraparound data loss in= database "db1" , sqlstate:54000 1) After reading the documentation, I thought I could try to vacuum those 2= 0 tables that were never vacuumed individually ( with relfrozenid more than= 2 billion) in single-user mode, but it is not working (error copied below)= . Is there a way to do vacuum of individual tables in single-user mode? I w= ould rather not do vacuum of all tables ("vacuum" command) as that would pr= obably take several days. backend> vacuum freeze schema.wd_p51_y2015; 2017-02-07 23:25:15 EST [54045]: [8-1] user=3D,db=3D,app=3D,client=3D WARNI= NG: database "db1" must be vacuumed within 999999 transactions 2017-02-07 23:25:15 EST [54045]: [9-1] user=3D,db=3D,app=3D,client=3D HINT:= To avoid a database shutdown, execute a database-wide VACUUM in that data= base. You might also need to commit or roll back old prepared transactions. 2) If "vacuum" ing the whole db is my only option, how can i execute singl= e-user mode in background with vacuum running? could someone please share a= n example? I can only execute "postgres --single DBNAME" in interactive mod= e and could not figure out sending it to background without the server term= inating on me. I only have remote access to this db server, and needs a way= to kick off the vacuum in single-user mode in the background. 3) Restoring from the backup is an option for us, but given the db size and= time to build indexes, but hoping to hear opinions from an expert or two. Thanks for your help in advance, Ganesh Kannan --_000_DM5PR07MB2747653DAC96763C3B4F785A86420DM5PR07MB2747namp_ Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable

Update...


I let the vacuum db for the night and i see there are about 10 tabl= es that were never vacuumed (reduced from 20 tables.)  


select t.relname, t.last_vacuum, t.last_autovacuum, c.relfrozenxid, ag= e(c.relfrozenxid)
 from pg_stat_user_tables t, pg_class  c
where schemaname=3D'weather_data'
and c.relkind=3D'r' 
and t.relid=3Dc.oid
and last_vacuum is null and last_auto= vacuum is null
order by last_vacuum desc, last_autov= acuum desc;

Adding that there are more than 1000 tables (each 14 GB or so) that ma= tch age(relfrozenxid)  > 

I could again take the database into single-user mode and let it run, bu= t not sure if vacuum would get to those 10 tables first or not. can someone= shed some light on the order in which manual vacuum or auto vacuum wo= uld pick up tables for vacuum? 


Regarding running the postgres --single in background, I used disow= n to let it run through overnight, but I had to kill the process to open th= e DB for read-only sessions. When i checked the pg_class.last_vacuum field,= I don't see any table was vacuumed though the process was running for 8 hours. Does killing the single user mode aff= ect "vacuum" from registering the fact it did vacuum on tables?


Thanks again, and I hope that there is = enough intrigue and information here to get someone willing to help me out.=

Ganesh



From: Ganesh Kannan
Sent: Wednesday, February 8, 2017 1:48:10 AM
To: pgsql-admin@postgresql.org
Subject: Recovery from Transaction wraparound failure
 


Hi All,


One of the production databases that we own is having transactions wrapa= round issue. This is a large database with more than 2000 tables, 70TB in s= ize. Most of the tables run between 14 to 20GB in size. This database is pr= edominantly read-only work load, but gets millions of new rows each day in batches. There are about 20 tabl= es that were never vacuumed manually or picked up by auto vacuum, and I sus= pect those may be the ones causing the issue. 


At first, I started seeing this error for all writes:

sqlerrm:database is not accepting commands to avoid wraparound data loss in= database "db1" , sqlstate:54000


1) After reading the documentation, I thought I could try to vacuum= those 20 tables that were never vacuumed individually ( with relfroze= nid more than 2 billion) in single-user mode, but it is not working (e= rror copied below). Is there a way to do vacuum of individual tables in single-user mode? I would rather not do vacuum of = all tables ("vacuum" command) as that would probably take several= days.


backend>&nb= sp; vacuum freeze schema.wd_p51_y2015;       

2017-02-07 23:= 25:15 EST [54045]: [8-1] user=3D,db=3D,app=3D,client=3D WARNING:  data= base "db1" must be vacuumed within 999999 transactions

2017-02-07 23:= 25:15 EST [54045]: [9-1] user=3D,db=3D,app=3D,client=3D HINT:  To avoi= d a database shutdown, execute a database-wide VACUUM in that database.

You might also need to commit or roll back old p= repared transactions.


2)  If "vacuum" ing the whole db is my only option, = how can i execute single-user mode in background with vacuum running? could= someone please share an example? I can only execute "postgres --= single DBNAME" in interactive mode and could not figure out sending it to background without the server terminating on me. I only have remote = access to this db server, and needs a way to kick off the vacuum in si= ngle-user mode in the background. 


3) Restoring from the backup is an option for us, but given the db = size and time to build indexes, but hoping to hear opinions from an expert = or two. 


Thanks for your help in advance,

Ganesh Kannan 

--_000_DM5PR07MB2747653DAC96763C3B4F785A86420DM5PR07MB2747namp_--