Received: from makus.postgresql.org (makus.postgresql.org [98.129.198.125]) by mail.postgresql.org (Postfix) with ESMTP id 78753119C297 for ; Thu, 8 Mar 2012 20:51:12 -0400 (AST) Received: from internet02.tru-signal.biz ([65.127.24.21] helo=internet02.xtechllc.com) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1S5o34-00055u-Je for pgsql-admin@postgresql.org; Fri, 09 Mar 2012 00:51:11 +0000 Received: from service02.office.ebureau.com (service02.office.ebureau.com [192.168.20.15]) by internet02.xtechllc.com (Postfix) with ESMTP id C56DBBD8094 for ; Thu, 8 Mar 2012 18:50:57 -0600 (CST) Received: from localhost (localhost [127.0.0.1]) by service02.office.ebureau.com (Postfix) with ESMTP id 9F5E693A586B for ; Thu, 8 Mar 2012 18:50:57 -0600 (CST) X-Virus-Scanned: amavisd-new at ebureau.com Received: from service02.office.ebureau.com ([127.0.0.1]) by localhost (service02.office.iscompanies.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id qHE-v4GNgIPz for ; Thu, 8 Mar 2012 18:50:57 -0600 (CST) Received: from punch.office.iscompanies.com (punch.office.iscompanies.com [10.10.20.24]) by service02.office.ebureau.com (Postfix) with ESMTPA id 29F4193A5857 for ; Thu, 8 Mar 2012 18:50:57 -0600 (CST) From: Natalie Wenz Content-Type: multipart/alternative; boundary="Apple-Mail=_95E486C7-E01E-4376-B518-48D5C5BF0D12" Subject: Vacuum to prevent wraparound data loss Date: Thu, 8 Mar 2012 18:50:57 -0600 References: <8CC19810-BB3B-4511-9DC4-0C38AE120B79@ebureau.com> To: pgsql-admin@postgresql.org Message-Id: <0008A0CD-58B3-4FC8-9976-E5D2B41E5E82@ebureau.com> Mime-Version: 1.0 (Apple Message framework v1257) X-Mailer: Apple Mail (2.1257) X-Pg-Spam-Score: -1.9 (-) X-Archive-Number: 201203/44 X-Sequence-Number: 39232 --Apple-Mail=_95E486C7-E01E-4376-B518-48D5C5BF0D12 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=windows-1252 Hi! I have a few questions regarding vacuum behavior. But first, some = background: We're running Postgres version 9.1.2 on FreeBSD 8.2 stable. We did a large data-only single table dump (table was 12TB when we = dumped it) and restored it on a new machine while our database was live = in the new location. It took over 2 weeks for this bulk table load to = finish, and since it took so long, and was also accepting inserts at the = same time, we ran into some trouble with the transaction ids. Here is the summary of events: 2/3 pg_restore started 2/6 autovacuum: VACUUM public.bigtable (to prevent wraparound) 2/17 noticed this in the logfile (may have started complaining earlier): = WARNING: oldest xmin is far in the past disabled external connections 2/21 restore finished reenabled external connections-left auto vacuum to finish WARNING: database "postgres" must be vacuumed within 1000001 = transactions ERROR: database is not accepting commands to avoid wraparound data loss = in database "postgres" disabled external connections =85 3/8 vacuum is still running. The cpu usage for that pid fluctuates = between 3% and 100%. We see it doing some reads and some writes. (Is = there any way to know what it's doing?) The logfile continues to be = spammed with: "ERROR: database is not accepting commands to avoid = wraparound data loss in database "postgres" HINT: Stop the postmaster = and use a standalone backend to vacuum that database." My first question is: Is it even possible for this vacuum to finish? It = began before the database stopped accepting connections, but now that = it's in this state, will the database allow the vacuum to complete? Can = the vacuum successfully freeze old xids and advance the datfrozenxid? I = suspect no, based on "(A manual VACUUM should fix the problem, as suggested by the hint; but = note that the VACUUM must be performed by a superuser, else it will fail = to process system catalogs and thus not be able to advance the = database's datfrozenxid.) If these warnings are ignored, the system will = shut down and refuse to execute any new transactions once there are = fewer than 1 million transactions left until wraparound." Can someone confirm? (And perhaps, explain why? And would a manual = vacuum executed from within the database work? Or only from the = standalone backend as the hint suggests?) If it is indeed the case that the autovacuum that is currently running = will be unsuccessful, then my next question is: Vacuum or vacuum freeze? = Would one of them run more quickly than the other? (Significantly?) Is = it possible/recommended to give the vacuum (or vacuum freeze) more = resources when using the standalone backend? Our current tuning = parameters and other possibly relevant information below. Any help or insight is greatly appreciated! =20 Thanks, Natalie 24GB of memory.=20 The database shows the "bigtable" size is 14TB, and the other table is = about 250GB. Disk space is 25TB total, 18TB used. system tuning: kern.ipc.semmni=3D87381 //Number of semaphore identifiers kern.ipc.semmns=3D87381 //Maximum number of semaphores in the system kern.ipc.semmnu=3D87381 //Maximum number of undo structures in the = system kern.ipc.shmmni=3D1024 //Number of shared memory identifiers kern.maxfiles=3D450000 /etc/sysctl.conf kern.ipc.shmmax=3D1073741824 //Maximum shared memory segment size kern.ipc.shmmin=3D1 //Minimum shared memory segment size kern.ipc.shmseg=3D128 //Number of segments per process kern.ipc.shmall=3D524288 //bumped up from 262144 //Maximum number of = pages available for shared memory postgres.conf--tuning parameters (changed from defaults or uncommented): max_connections =3D 500 shared_buffers =3D 128MB temp_buffers =3D 64MB work_mem =3D 128MB maintenance_work_mem =3D 1024MB synchronous_commit =3D off seq_page_cost =3D 1.0 random_page_cost =3D 1.0 effective_cache_size =3D 12GB=20 vacuum_cost_limit =3D 500 wal_buffers =3D 16MB checkpoint_segments =3D 128 autovacuum =3D on log_autovacuum_min_duration =3D 10000 autovacuum_max_workers =3D 3 autovacuum_vacuum_scale_factor =3D 0.1 autovacuum_analyze_scale_factor =3D 0.1 autovacuum_freeze_max_age =3D 800000000 autovacuum_vacuum_cost_delay =3D 0ms --Apple-Mail=_95E486C7-E01E-4376-B518-48D5C5BF0D12 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=windows-1252 Hi!

I have a = few questions regarding vacuum behavior.  But first, some = background:

We're running Postgres = version 9.1.2 on FreeBSD 8.2 stable.

We = did a large data-only single table dump (table was 12TB when we dumped = it) and restored it on a new machine while our database was live in the = new location. It took over 2 weeks for this bulk table load to finish, = and since it took so long, and was also accepting inserts at the same = time, we ran into some trouble with the transaction = ids.

Here is the summary of = events:

2/3  pg_restore = started
2/6  autovacuum: VACUUM public.bigtable (to = prevent wraparound)
2/17 noticed this in the logfile (may have = started complaining earlier):  WARNING:  oldest xmin is far in = the past
disabled external connections
2/21 =  restore finished
reenabled external connections-left = auto vacuum to finish
WARNING:  database "postgres" must = be vacuumed within 1000001 transactions
ERROR:  database = is not accepting commands to avoid wraparound data loss in database = "postgres"
disabled external connections
=85 3/8 =  vacuum is still running. The cpu usage for that pid fluctuates = between 3% and 100%. We see it doing some reads and some writes. =  (Is there any way to know what it's doing?) The logfile continues = to be spammed with: "ERROR:  database is not accepting commands to = avoid wraparound data loss in database "postgres"   HINT: =  Stop the postmaster and use a standalone backend to vacuum that = database."


=
My first question is: Is it even possible for this vacuum to = finish? It began before the database stopped accepting connections, but = now that it's in this state, will the database allow the vacuum to = complete? Can the vacuum successfully freeze old xids and advance the = datfrozenxid?  I suspect no, based = on

"(A manual  should = fix the problem, as suggested by the hint; but note that = the VACUUM must be performed by a = superuser, else it will fail to process system catalogs and thus not = be able to advance the database's datfrozenxid.) If these warnings are ignored, = the system will shut down and refuse to execute any new transactions = once there are fewer than 1 million transactions left until = wraparound."

Can someone = confirm?  (And perhaps, explain why? And would a manual vacuum = executed from within the database work? Or only from the standalone = backend as the hint suggests?)

If it is indeed = the case that the autovacuum that is currently running will be = unsuccessful, then my next question is: Vacuum or vacuum freeze? =  Would one of them run more quickly than the other? = (Significantly?)  Is it possible/recommended to give the vacuum (or = vacuum freeze) more resources when using the standalone backend? =  Our current tuning parameters  and other possibly relevant = information below.


Any help or = insight is greatly appreciated! =  

Thanks,
Natalie
<= br>



24GB of = memory. 
The database shows the "bigtable" size is 14TB, = and the other table is about 250GB.  Disk space is 25TB total, 18TB = used.

system = tuning:

kern.ipc.semmni=3D87381 =  //Number of semaphore identifiers
kern.ipc.semmns=3D87381 =  //Maximum number of semaphores in the = system
kern.ipc.semmnu=3D87381  //Maximum number of undo = structures in the system
kern.ipc.shmmni=3D1024  //Number = of shared memory = identifiers
kern.maxfiles=3D450000

/etc= /sysctl.conf
kern.ipc.shmmax=3D1073741824   //Maximum = shared memory segment size
kern.ipc.shmmin=3D1   = //Minimum shared memory segment size
kern.ipc.shmseg=3D128 =   //Number of segments per process
kern.ipc.shmall=3D524288=   //bumped up from 262144   //Maximum number of pages = available for shared = memory


postgres.conf--tuning = parameters (changed from defaults or = uncommented):

max_connections =3D = 500
shared_buffers =3D 128MB
temp_buffers =3D = 64MB
work_mem =3D 128MB
maintenance_work_mem =3D = 1024MB
synchronous_commit =3D off
seq_page_cost =3D = 1.0
random_page_cost =3D 1.0
effective_cache_size =3D = 12GB 
vacuum_cost_limit =3D 500
wal_buffers =3D = 16MB
checkpoint_segments =3D 128
autovacuum =3D = on
log_autovacuum_min_duration =3D = 10000
autovacuum_max_workers =3D = 3
autovacuum_vacuum_scale_factor =3D = 0.1
autovacuum_analyze_scale_factor =3D = 0.1
autovacuum_freeze_max_age =3D = 800000000
autovacuum_vacuum_cost_delay =3D = 0ms



= --Apple-Mail=_95E486C7-E01E-4376-B518-48D5C5BF0D12--