pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Alvaro Herrera <alvherre@2ndquadrant.com>
To: dvitek@grammatech.com
Cc: pgsql-bugs@postgresql.org
Subject: Re: BUG #9190: Could not fsync file "pg_clog/0000": Bad file descriptor.
Date: Wed, 12 Feb 2014 11:16:07 -0300
Message-ID: <20140212141607.GJ6342@eldon.alvh.no-ip.org> (raw)
In-Reply-To: <20140211222906.2717.71884@wrigleys.postgresql.org>
References: <20140211222906.2717.71884@wrigleys.postgresql.org>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

dvitek@grammatech.com wrote:

> We had a postgres panic a few weeks ago.  Here is a relevant fragment of the
> postgres log:
> 
> [2014-01-27 04:57:37 EST 3756] WARNING:  pgstat wait timeout
> ...
> ...
> ...
> [2014-01-27 04:55:36 EST 5804] ERROR:  could not access status of
> transaction 0
> [2014-01-27 04:55:42 EST 5804] DETAIL:  Could not fsync file "pg_clog/0000":
> Bad file descriptor.

I noticed that SimpleLruFlush calls SlruInternalWritePage() to write all
pages, and stores the file descriptors in fdata, with the intention of
fsyncing the files later; SlruInternalWritePage in turn calls
SlruPhysicalWritePage.  If the physical write fails,
SlruInternalWritePage will dutifully close all the files, *but fdata is
not updated to remove the file descriptors*.  This might lead to the
"bad file descriptor" error (but see below).  Really, what we should be
reporting is the failure to do the writes, I think.  There is something
broken about this system that makes the writes fail (something which can
probably be learnt about in the kernel log, if there is such a thing on
Windows), but this part seems our bug.

The "status of transaction 0" part of the error message should surprise
no one, since InvalidTransactionId is what SimpleLruFlush uses in its
failure report.

This does nothing to explain or help with the PANIC, however; nor why
things seem to have continued running after a PANIC for two minutes.

> [2014-01-27 09:21:04 EST 3080] PANIC:  could not fsync file "pg_xlog/xlogtemp.3080": Bad file descriptor
> [2014-01-27 09:23:01 EST 5404] LOG:  WAL writer process (PID 3080) exited with exit code 3
> [2014-01-27 09:23:07 EST 5404] LOG:  terminating any other active server processes

There is no obvious path in which an fd is clobbered in xlog.c that I
can see.  If there is an explanation for this failure at the filesystem
level, perhaps that can explain the above problem as well.

-- 
Álvaro Herrera                http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



view thread (2+ messages)

Message-ID: <20140212141607.GJ6342@eldon.alvh.no-ip.org>
Permalink:  ../20140212141607.GJ6342@eldon.alvh.no-ip.org/
Also on:    postgresql.org/message-id/20140212141607.GJ6342@eldon.alvh.no-ip.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: alvherre@2ndquadrant.com, dvitek@grammatech.com
  Subject: Re: BUG #9190: Could not fsync file "pg_clog/0000": Bad file descriptor.
  In-Reply-To: <20140212141607.GJ6342@eldon.alvh.no-ip.org>
  References: <20140211222906.2717.71884@wrigleys.postgresql.org> <20140212141607.GJ6342@eldon.alvh.no-ip.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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