pg.ddx.io pgsql-performance@postgresql.org mailing list archive
help / color / mirror / Atom feedWAL partition filling up after high WAL activity
4+ messages / 3 participants
[nested] [flat]
* WAL partition filling up after high WAL activity
@ 2011-11-07 22:18 Richard Yen <richyen@iparadigms.com>
2011-11-09 16:06 ` Re: WAL partition filling up after high WAL activity Greg Smith <greg@2ndQuadrant.com>
0 siblings, 1 reply; 4+ messages in thread
From: Richard Yen @ 2011-11-07 22:18 UTC (permalink / raw)
To: pgsql-performance
Hi Everyone,
I recently saw a crash on one of our databases, and I was wondering if this
might be an indication of something with WAL that might be unexpectedly
creating more files than it needs to?
Nov 5 16:18:27 localhost postgres[25092]: [111-1] 2011-11-05 16:18:27.524
PDT [user=slony,db=uk dbhub.com <http://dbhub.sac.iparadigms.com/>(35180)
PID:25092 XID:2142895751]PANIC: could not write to file
"pg_xlog/xlogtemp.25092": No space left on device
Nov 5 16:18:27 localhost postgres[25092]: [111-2] 2011-11-05 16:18:27.524
PDT [user=slony,db=uk dbhub.com <http://dbhub.sac.iparadigms.com/>(35180)
PID:25092 XID:2142895751]STATEMENT: select "_sac_uk".forwardConfirm(2, 4, '
5003717188', '2011-11-05 16:18:26.977112');
Nov 5 16:18:27 localhost postgres[32121]: [7-1] 2011-11-05 16:18:27.531
PDT [user=,db= PID:32121 XID:0]LOG: server process (PID 25092) was
terminated by signal 6: Aborted
Nov 5 16:18:27 localhost postgres[32121]: [8-1] 2011-11-05 16:18:27.531
PDT [user=,db= PID:32121 XID:0]LOG: terminating any other active server
processes
If you look at this graph (http://cl.ly/2y0W27330t3o2J281H3K), the
partition actually fills up, and the logs show that postgres crashed.
After postgres crashed, it automatically restarted, cleared out its WAL
files, and began processing things again at 4:30PM.
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: WAL partition filling up after high WAL activity
2011-11-07 22:18 WAL partition filling up after high WAL activity Richard Yen <richyen@iparadigms.com>
@ 2011-11-09 16:06 ` Greg Smith <greg@2ndQuadrant.com>
2011-11-11 09:54 ` Re: WAL partition filling up after high WAL activity Rafael Martinez <r.m.guerrero@usit.uio.no>
0 siblings, 1 reply; 4+ messages in thread
From: Greg Smith @ 2011-11-09 16:06 UTC (permalink / raw)
To: pgsql-performance
On 11/07/2011 05:18 PM, Richard Yen wrote:
> My biggest question is: we know from the docs that there should be no
> more than (2 + checkpoint_completion_target) * checkpoint_segments + 1
> files. For us, that would mean no more than 48 files, which equates
> to 384MB--far lower than the 9.7GB partition size. **Why would WAL
> use up so much disk space?**
>
That's only true if things are operating normally. There are at least
two ways this can fail to be a proper upper limit on space used:
1) You are archiving to a second system, and the archiving isn't keeping
up. Things that haven't been archived can't be re-used, so more disk
space is used.
2) Disk I/O is slow, and the checkpoint writes take a significant period
of time. The internal scheduling assumes each individual write will
happen without too much delay. That assumption can easily be untrue on
a busy system. The worst I've seen now are checkpoints that take 6
hours to sync, where the time is supposed to be a few seconds. Disk
space in that case was a giant multiple of checkpoint_segments. (The
source of that problem is very much improved in PostgreSQL 9.1)
The info needed to figure out which category you're in would appear
after tuning log_checkpoints on in the postgresql.conf ; you only need
to reload the server config after that, doesn't require a restart. I
would guess you have realy long sync times there.
As for what to do about it, checkpoint_segments=16 is a low setting.
You might as well set it to a large number, say 128, and let checkpoints
get driven by time instead. The existing limit isn't working
effectively anyway, and having more segments lets the checkpoint
spreading code work more evenly.
--
Greg Smith 2ndQuadrant US greg@2ndQuadrant.com Baltimore, MD
PostgreSQL Training, Services, and 24x7 Support www.2ndQuadrant.us
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: WAL partition filling up after high WAL activity
2011-11-07 22:18 WAL partition filling up after high WAL activity Richard Yen <richyen@iparadigms.com>
2011-11-09 16:06 ` Re: WAL partition filling up after high WAL activity Greg Smith <greg@2ndQuadrant.com>
@ 2011-11-11 09:54 ` Rafael Martinez <r.m.guerrero@usit.uio.no>
2011-11-12 06:31 ` Re: WAL partition filling up after high WAL activity Greg Smith <greg@2ndQuadrant.com>
0 siblings, 1 reply; 4+ messages in thread
From: Rafael Martinez @ 2011-11-11 09:54 UTC (permalink / raw)
To: Greg Smith <greg@2ndQuadrant.com>; +Cc: pgsql-performance
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On 11/09/2011 05:06 PM, Greg Smith wrote:
> On 11/07/2011 05:18 PM, Richard Yen wrote:
>> My biggest question is: we know from the docs that there should be no
>> more than (2 + checkpoint_completion_target) * checkpoint_segments + 1
>> files. For us, that would mean no more than 48 files, which equates
>> to 384MB--far lower than the 9.7GB partition size. **Why would WAL
>> use up so much disk space?**
>>
>
> That's only true if things are operating normally. There are at least
> two ways this can fail to be a proper upper limit on space used:
>
> 1) You are archiving to a second system, and the archiving isn't keeping
> up. Things that haven't been archived can't be re-used, so more disk
> space is used.
>
> 2) Disk I/O is slow, and the checkpoint writes take a significant period
> of time. The internal scheduling assumes each individual write will
> happen without too much delay. That assumption can easily be untrue on
> a busy system. The worst I've seen now are checkpoints that take 6
> hours to sync, where the time is supposed to be a few seconds. Disk
> space in that case was a giant multiple of checkpoint_segments. (The
> source of that problem is very much improved in PostgreSQL 9.1)
>
Hello
We have a similar case in june but we did not find the cause of our
problem. More details and information:
http://archives.postgresql.org/pgsql-docs/2011-06/msg00007.php
Your explanation in 2) sounds like a good candidate for the problem we
had. As I said in june, I think we need to improve the documentation in
this area. A note in the documentation about what you have explained in
2) with maybe some hints about how to find out if this is happening will
be a great improvement.
We did not understand why we experienced this problem in june when
creating a GIN index on a tsvector column. But we found out that a lot
of the tsvector data was generated from "garbage" data (base64 encoding
of huge attachments). When we generated the right tsvector data, the
creation of the GIN index ran smoothly and the problem with extra WAL
files disappeared.
PS.- In our case, the disk space used by all the extra WAL files was
almost the equivalent to the 17GB of our GIN index.
regards,
- --
Rafael Martinez Guerrero
Center for Information Technology
University of Oslo, Norway
PGP Public Key: http://folk.uio.no/rafael/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iEYEARECAAYFAk688LoACgkQBhuKQurGihTbvQCfaSBdYNF2oOtErcx/e4u0Zw1J
pLIAn2Ztdbuz33es2uw8ddSIjj8UXe3s
=olkD
-----END PGP SIGNATURE-----
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: WAL partition filling up after high WAL activity
2011-11-07 22:18 WAL partition filling up after high WAL activity Richard Yen <richyen@iparadigms.com>
2011-11-09 16:06 ` Re: WAL partition filling up after high WAL activity Greg Smith <greg@2ndQuadrant.com>
2011-11-11 09:54 ` Re: WAL partition filling up after high WAL activity Rafael Martinez <r.m.guerrero@usit.uio.no>
@ 2011-11-12 06:31 ` Greg Smith <greg@2ndQuadrant.com>
0 siblings, 0 replies; 4+ messages in thread
From: Greg Smith @ 2011-11-12 06:31 UTC (permalink / raw)
To: Rafael Martinez <r.m.guerrero@usit.uio.no>; +Cc: pgsql-performance
On 11/11/2011 04:54 AM, Rafael Martinez wrote:
> Your explanation in 2) sounds like a good candidate for the problem we
> had. As I said in june, I think we need to improve the documentation in
> this area. A note in the documentation about what you have explained in
> 2) with maybe some hints about how to find out if this is happening will
> be a great improvement.
>
A new counter was added to pg_stat_bgwriter in PostgreSQL 9.1 that
tracks when the problem I described happens. It's hard to identify it
specifically without a source code change of some sort. Initially I
added new logging to the server code to identify the issue before the
new counter was there. The only thing you can easily look at that tends
to correlate well with the worst problems here is the output from
turning log_checkpoint on. Specifically, the "sync" times going way up
is a sign there's a problem with write speed.
As for the documentation, not much has really changed from when you
brought this up on the docs list. The amount of WAL files that can be
created by a "short-term peak" is unlimited, which is why there's no
better limit listed than that. Some of the underlying things that make
the problem worse are operating system level issues, not ones in the
database itself; the PostgreSQL documentation doesn't try to wander too
far into that level. There are also a large number of things you can do
at the application level that will generate a lot of WAL activity. It
would be impractical to list all of them in the checkpoint documentation
though.
On reviewing this section of the docs again, one thing that we could do
is make the "WAL Configuration" section talk more about log_checkpoints
and interpreting its output. Right now there's no mention of that
parameter in the section that talks about parameters to configure; there
really should be.
--
Greg Smith 2ndQuadrant US greg@2ndQuadrant.com Baltimore, MD
PostgreSQL Training, Services, and 24x7 Support www.2ndQuadrant.us
^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2011-11-12 06:31 UTC | newest]
Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2011-11-07 22:18 WAL partition filling up after high WAL activity Richard Yen <richyen@iparadigms.com>
2011-11-09 16:06 ` Greg Smith <greg@2ndQuadrant.com>
2011-11-11 09:54 ` Rafael Martinez <r.m.guerrero@usit.uio.no>
2011-11-12 06:31 ` Greg Smith <greg@2ndQuadrant.com>
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