Unix Technical Forum

URGENT: Out of disk space pg_xlog

This is a discussion on URGENT: Out of disk space pg_xlog within the Pgsql Performance forums, part of the PostgreSQL category; --> "Kevin Grittner" <Kevin.Grittner@wicourts.gov> writes: > Tom Lane <tgl@sss.pgh.pa.us> wrote: >> before the system crash? The scenario we've seen in ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > Pgsql Performance

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #11 (permalink)  
Old 04-19-2008, 09:59 AM
Tom Lane
 
Posts: n/a
Default Re: URGENT: Out of disk space pg_xlog

"Kevin Grittner" <Kevin.Grittner@wicourts.gov> writes:
> Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> before the system crash? The scenario we've seen in the past is
>>
>> * data partition out of space, so writes fail
>> * each time Postgres attempts a checkpoint, writes fail, so the
>> checkpoint fails. No data loss at this point, the dirty buffers
>> just stay in memory.
>> * pg_xlog bloats because we can't truncate away old segments


> So, at this point, if space is freed on the data partition somehow,
> Postgres recovers with no problems? (i.e.,, the database is still
> running and no requests have been terminated abnormally due to the space
> problems?)


Right, no committed transactions have been lost. Depending on what you
are doing, you might see individual transactions fail due to
out-of-space --- an INSERT/UPDATE that couldn't find free space within
its table would probably fail while trying to extend the table, and
anything requiring a large temp file would fail.

> Just to confirm what I would assume at this point -- non-committed
> transactions should roll back cleanly; it is reasonable to assume no
> corruption at this point?


Yeah, I would expect no problems.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
choose an index scan if your joining column's datatypes do not
match

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #12 (permalink)  
Old 04-19-2008, 09:59 AM
ohp@pyrenet.fr
 
Posts: n/a
Default Re: URGENT: Out of disk space pg_xlog

On Fri, 22 Dec 2006, Tom Lane wrote:

> Date: Fri, 22 Dec 2006 13:14:18 -0500
> From: Tom Lane <tgl@sss.pgh.pa.us>
> To: Kevin Grittner <Kevin.Grittner@wicourts.gov>
> Cc: Jeremy Haile <jhaile@fastmail.fm>, pgsql-performance@postgresql.org
> Subject: Re: [PERFORM] URGENT: Out of disk space pg_xlog
>
> "Kevin Grittner" <Kevin.Grittner@wicourts.gov> writes:
> > As I understand it, the log space accumulates for the oldest transaction
> > which is still running, and all transactions which started after it.

>
> No, pg_xlog can be truncated as soon as a checkpoint occurs.


Even for currently running transactions ?

My understanding was that checkpoint was syncing data files for commited
transactions.

What happens to pg_xlogs when a transaction updates M of rows/tables and
runs for hours?
[snip]
>
> regards, tom lane
>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Have you searched our list archives?
>
> http://archives.postgresql.org
>

regards
--
Olivier PRENANT Tel: +33-5-61-50-97-00 (Work)
15, Chemin des Monges +33-5-61-50-97-01 (Fax)
31190 AUTERIVE +33-6-07-63-80-64 (GSM)
FRANCE Email: ohp@pyrenet.fr
------------------------------------------------------------------------------
Make your life a dream, make your dream a reality. (St Exupery)

---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
choose an index scan if your joining column's datatypes do not
match

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #13 (permalink)  
Old 04-19-2008, 09:59 AM
Tom Lane
 
Posts: n/a
Default Re: URGENT: Out of disk space pg_xlog

ohp@pyrenet.fr writes:
> On Fri, 22 Dec 2006, Tom Lane wrote:
>> No, pg_xlog can be truncated as soon as a checkpoint occurs.


> Even for currently running transactions ?


Yes.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql.org so that your
message can get through to the mailing list cleanly

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #14 (permalink)  
Old 04-19-2008, 09:59 AM
Alvaro Herrera
 
Posts: n/a
Default Re: URGENT: Out of disk space pg_xlog

ohp@pyrenet.fr wrote:
> On Fri, 22 Dec 2006, Tom Lane wrote:
>
> > Date: Fri, 22 Dec 2006 13:14:18 -0500
> > From: Tom Lane <tgl@sss.pgh.pa.us>
> > To: Kevin Grittner <Kevin.Grittner@wicourts.gov>
> > Cc: Jeremy Haile <jhaile@fastmail.fm>, pgsql-performance@postgresql.org
> > Subject: Re: [PERFORM] URGENT: Out of disk space pg_xlog
> >
> > "Kevin Grittner" <Kevin.Grittner@wicourts.gov> writes:
> > > As I understand it, the log space accumulates for the oldest transaction
> > > which is still running, and all transactions which started after it.

> >
> > No, pg_xlog can be truncated as soon as a checkpoint occurs.

>
> Even for currently running transactions ?
>
> My understanding was that checkpoint was syncing data files for commited
> transactions.


No, it syncs data files for all transactions, even those currently
running.

> What happens to pg_xlogs when a transaction updates M of rows/tables and
> runs for hours?


They get recycled as the update goes.

--
Alvaro Herrera http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.

---------------------------(end of broadcast)---------------------------
TIP 3: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faq

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #15 (permalink)  
Old 04-19-2008, 09:59 AM
Steinar H. Gunderson
 
Posts: n/a
Default Re: URGENT: Out of disk space pg_xlog

On Fri, Dec 22, 2006 at 07:47:05PM +0100, ohp@pyrenet.fr wrote:
>> No, pg_xlog can be truncated as soon as a checkpoint occurs.

> Even for currently running transactions ?


Isn't that the entire point of having checkpoints in the first place? :-)

/* Steinar */
--
Homepage: http://www.sesse.net/

---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
choose an index scan if your joining column's datatypes do not
match

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #16 (permalink)  
Old 04-19-2008, 09:59 AM
Bruce Momjian
 
Posts: n/a
Default Re: URGENT: Out of disk space pg_xlog

Tom Lane wrote:
> "Kevin Grittner" <Kevin.Grittner@wicourts.gov> writes:
> > As I understand it, the log space accumulates for the oldest transaction
> > which is still running, and all transactions which started after it.

>
> No, pg_xlog can be truncated as soon as a checkpoint occurs. If Jeremy
> wasn't using archive_command then the only possible explanation for
> bloated pg_xlog is that checkpoints were failing. Which is not unlikely
> if the *data* partition runs out of space. Were there gripes in the log
> before the system crash? The scenario we've seen in the past is
>
> * data partition out of space, so writes fail
> * each time Postgres attempts a checkpoint, writes fail, so the
> checkpoint fails. No data loss at this point, the dirty buffers
> just stay in memory.
> * pg_xlog bloats because we can't truncate away old segments
> * eventually pg_xlog runs out of space, at which point we PANIC
> and can't continue running the database
>
> Once you free some space on the data partition and restart, you should
> be good to go --- there will be no loss of committed transactions, since
> all the operations are in pg_xlog. Might take a little while to replay
> all that log though :-(


Amazing that all works. What I did not see is confirmation from the
user that the data directory filled up _before_ pg_xlog filled up.

--
Bruce Momjian bruce@momjian.us
EnterpriseDB http://www.enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +

---------------------------(end of broadcast)---------------------------
TIP 4: Have you searched our list archives?

http://archives.postgresql.org

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #17 (permalink)  
Old 04-19-2008, 09:59 AM
ohp@pyrenet.fr
 
Posts: n/a
Default Re: URGENT: Out of disk space pg_xlog

Thanks for your reply.

I learnt something again!
On Fri, 22 Dec 2006, Alvaro Herrera wrote:

> Date: Fri, 22 Dec 2006 17:25:43 -0300
> From: Alvaro Herrera <alvherre@commandprompt.com>
> To: ohp@pyrenet.fr
> Cc: Tom Lane <tgl@sss.pgh.pa.us>,
> Kevin Grittner <Kevin.Grittner@wicourts.gov>,
> Jeremy Haile <jhaile@fastmail.fm>, pgsql-performance@postgresql.org
> Subject: Re: [PERFORM] URGENT: Out of disk space pg_xlog
>
> ohp@pyrenet.fr wrote:
> > On Fri, 22 Dec 2006, Tom Lane wrote:
> >
> > > Date: Fri, 22 Dec 2006 13:14:18 -0500
> > > From: Tom Lane <tgl@sss.pgh.pa.us>
> > > To: Kevin Grittner <Kevin.Grittner@wicourts.gov>
> > > Cc: Jeremy Haile <jhaile@fastmail.fm>, pgsql-performance@postgresql.org
> > > Subject: Re: [PERFORM] URGENT: Out of disk space pg_xlog
> > >
> > > "Kevin Grittner" <Kevin.Grittner@wicourts.gov> writes:
> > > > As I understand it, the log space accumulates for the oldest transaction
> > > > which is still running, and all transactions which started after it.
> > >
> > > No, pg_xlog can be truncated as soon as a checkpoint occurs.

> >
> > Even for currently running transactions ?
> >
> > My understanding was that checkpoint was syncing data files for commited
> > transactions.

>
> No, it syncs data files for all transactions, even those currently
> running.
>
> > What happens to pg_xlogs when a transaction updates M of rows/tables and
> > runs for hours?

>
> They get recycled as the update goes.
>
>


--
Olivier PRENANT Tel: +33-5-61-50-97-00 (Work)
15, Chemin des Monges +33-5-61-50-97-01 (Fax)
31190 AUTERIVE +33-6-07-63-80-64 (GSM)
FRANCE Email: ohp@pyrenet.fr
------------------------------------------------------------------------------
Make your life a dream, make your dream a reality. (St Exupery)

---------------------------(end of broadcast)---------------------------
TIP 7: You can help support the PostgreSQL project by donating at

http://www.postgresql.org/about/donate

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #18 (permalink)  
Old 04-19-2008, 09:59 AM
Jeremy Haile
 
Posts: n/a
Default Re: URGENT: Out of disk space pg_xlog

> > Once you free some space on the data partition and restart, you should
> > be good to go --- there will be no loss of committed transactions, since
> > all the operations are in pg_xlog. Might take a little while to replay
> > all that log though :-(

>
> Amazing that all works. What I did not see is confirmation from the
> user that the data directory filled up _before_ pg_xlog filled up.


After I freed up space on the pg_xlog partition and restarted, it took
some time to replay all of the log (15-20 minutes) and everything
recovered with no data corruption! However, the theory about the data
partition filling up first didn't happen in my case. The data partition
was (and still is) less than 50% utilized. My pg_xlog files typically
run around 400MB, but with the long running update filled up the entire
10GB partition. (which is now a 70 GB partition)

So, I'm still not sure what caused the problem. When I get back to work
(or maybe sooner), I'll take a look in the PG logs and post anything
that looks suspicious here. Thanks for all of your comments and
suggestions. Even though I haven't figured out the root of the problem
yet, they've been very informative.

---------------------------(end of broadcast)---------------------------
TIP 3: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faq

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #19 (permalink)  
Old 04-19-2008, 09:59 AM
Bruce Momjian
 
Posts: n/a
Default Re: URGENT: Out of disk space pg_xlog

Jeremy Haile wrote:
> > > Once you free some space on the data partition and restart, you should
> > > be good to go --- there will be no loss of committed transactions, since
> > > all the operations are in pg_xlog. Might take a little while to replay
> > > all that log though :-(

> >
> > Amazing that all works. What I did not see is confirmation from the
> > user that the data directory filled up _before_ pg_xlog filled up.

>
> After I freed up space on the pg_xlog partition and restarted, it took
> some time to replay all of the log (15-20 minutes) and everything
> recovered with no data corruption! However, the theory about the data
> partition filling up first didn't happen in my case. The data partition
> was (and still is) less than 50% utilized. My pg_xlog files typically
> run around 400MB, but with the long running update filled up the entire
> 10GB partition. (which is now a 70 GB partition)
>
> So, I'm still not sure what caused the problem. When I get back to work
> (or maybe sooner), I'll take a look in the PG logs and post anything
> that looks suspicious here. Thanks for all of your comments and
> suggestions. Even though I haven't figured out the root of the problem
> yet, they've been very informative.


The bottom line is that we know of now cases where a long-running
transaction would delay recycling of the WAL files, so there is
certainly something not understood here.

--
Bruce Momjian bruce@momjian.us
EnterpriseDB http://www.enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +

---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql.org so that your
message can get through to the mailing list cleanly

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #20 (permalink)  
Old 04-19-2008, 10:00 AM
Simon Riggs
 
Posts: n/a
Default Re: URGENT: Out of disk space pg_xlog

On Sat, 2006-12-23 at 13:13 -0500, Bruce Momjian wrote:

> The bottom line is that we know of now cases where a long-running
> transaction would delay recycling of the WAL files, so there is
> certainly something not understood here.


We can see from all of this that a checkpoint definitely didn't occur.
Tom's causal chain was just one way that could have happened, there
could well be others.

I've noticed previously that a checkpoint can be starved out when trying
to acquire the CheckpointStartLock. I've witnessed a two minute delay
plus in obtaining the lock in the face of heavy transactions.

If wal_buffers is small enough, WAL write rate high enough and the
transaction rate high enough, a long queue can form for the
WALWriteLock, which ensures that the CheckpointStartLock would queue
indefinitely.

I've tried implementing a queueable shared lock for the
CheckpointStartLock. That helps the checkpoint, but it harms performance
of other transactions waiting to commit, so I let that idea go.

--
Simon Riggs
EnterpriseDB http://www.enterprisedb.com



---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
choose an index scan if your joining column's datatypes do not
match

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 05:28 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
www.UnixAdminTalk.com