Re: BUG #6372: Error while creating database with fsync parameter as on incase of CIFS

Lists: pgsql-bugs
From: anjali_524(at)yahoo(dot)co(dot)in
To: pgsql-bugs(at)postgresql(dot)org
Subject: BUG #6372: Error while creating database with fsync parameter as on incase of CIFS
Date: 2012-01-02 16:27:12
Message-ID: E1RhkjA-0005bq-B6@wrigleys.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs

The following bug has been logged on the website:

Bug reference: 6372
Logged by: Anjali Arora
Email address: anjali_524(at)yahoo(dot)co(dot)in
PostgreSQL version: 9.0.4
Operating system: Cent OS
Description:

The 8.2.2 postgres version works well with default fsync value on CIFS
2.6.32.

This problem seems to be specific to postgres 9.0.4 release

Error Message:

PST ERROR: could not fsync file "base/16409": Invalid argument Dec 30
03:00:26 devok64-8 postgres_cifs_kaz_1[15812]: [2-2] [local] 15812
2011-12-30 03:00:26.511 PST STATEMENT: CREATE DATABASE "KazDB

Please help to make it work.


From: Magnus Hagander <magnus(at)hagander(dot)net>
To: anjali_524(at)yahoo(dot)co(dot)in
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #6372: Error while creating database with fsync parameter as on incase of CIFS
Date: 2012-01-02 19:41:51
Message-ID: CABUevEzRd6TT89dx5AG_ceLgrvg7KTpCFmM8=iKvVL-HRHoM6w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs

On Mon, Jan 2, 2012 at 17:27, <anjali_524(at)yahoo(dot)co(dot)in> wrote:
> The following bug has been logged on the website:
>
> Bug reference:      6372
> Logged by:          Anjali Arora
> Email address:      anjali_524(at)yahoo(dot)co(dot)in
> PostgreSQL version: 9.0.4
> Operating system:   Cent OS
> Description:
>
> The 8.2.2 postgres version works well with default fsync value on CIFS
> 2.6.32.

It does not, really. It may appear to, but it does not.

> This problem seems to be specific to postgres 9.0.4 release
>
> Error Message:
>
> PST ERROR:  could not fsync file "base/16409": Invalid argument Dec 30
> 03:00:26 devok64-8 postgres_cifs_kaz_1[15812]: [2-2] [local] 15812
> 2011-12-30 03:00:26.511 PST STATEMENT:  CREATE DATABASE "KazDB
>
> Please help to make it work.

PostgreSQL does not support data directory over CIFS.

--
 Magnus Hagander
 Me: http://www.hagander.net/
 Work: http://www.redpill-linpro.com/


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Magnus Hagander <magnus(at)hagander(dot)net>
Cc: anjali_524(at)yahoo(dot)co(dot)in, pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #6372: Error while creating database with fsync parameter as on incase of CIFS
Date: 2012-01-02 20:14:32
Message-ID: 1149.1325535272@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs

Magnus Hagander <magnus(at)hagander(dot)net> writes:
> On Mon, Jan 2, 2012 at 17:27, <anjali_524(at)yahoo(dot)co(dot)in> wrote:
>> PST ERROR: could not fsync file "base/16409": Invalid argument Dec 30
>> 03:00:26 devok64-8 postgres_cifs_kaz_1[15812]: [2-2] [local] 15812
>> 2011-12-30 03:00:26.511 PST STATEMENT: CREATE DATABASE "KazDB

The specific error seems to be coming from copydir.c's attempt to fsync
a directory. We are already ignoring EBADF there, and could presumably
fix at least this symptom if we ignored EINVAL.

> PostgreSQL does not support data directory over CIFS.

I'm wondering what's your basis for asserting we don't support CIFS in
general? It's probably not terribly bulletproof, but any worse than NFS?

regards, tom lane


From: Magnus Hagander <magnus(at)hagander(dot)net>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: anjali_524(at)yahoo(dot)co(dot)in, pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #6372: Error while creating database with fsync parameter as on incase of CIFS
Date: 2012-01-02 20:18:27
Message-ID: CABUevEww2AKdVqU3n8wi-zpSsqVPKn8xxCk4io3nzv6O7UZMqQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs

On Mon, Jan 2, 2012 at 21:14, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Magnus Hagander <magnus(at)hagander(dot)net> writes:
>> On Mon, Jan 2, 2012 at 17:27,  <anjali_524(at)yahoo(dot)co(dot)in> wrote:
>>> PST ERROR:  could not fsync file "base/16409": Invalid argument Dec 30
>>> 03:00:26 devok64-8 postgres_cifs_kaz_1[15812]: [2-2] [local] 15812
>>> 2011-12-30 03:00:26.511 PST STATEMENT:  CREATE DATABASE "KazDB
>
> The specific error seems to be coming from copydir.c's attempt to fsync
> a directory.  We are already ignoring EBADF there, and could presumably
> fix at least this symptom if we ignored EINVAL.

Sure, we could - and I guess if you're running over CIFS, reliability
might not be the biggest concern in the first place...

>> PostgreSQL does not support data directory over CIFS.
>
> I'm wondering what's your basis for asserting we don't support CIFS in
> general?  It's probably not terribly bulletproof, but any worse than NFS?

Yes, it is a lot worse than NFS from experience. I can't find a
reference to it anywhere now, but IIRC there are bigger issues - with
blocksizes, with syncing not properly, with write ordering.

--
 Magnus Hagander
 Me: http://www.hagander.net/
 Work: http://www.redpill-linpro.com/


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Magnus Hagander <magnus(at)hagander(dot)net>
Cc: anjali_524(at)yahoo(dot)co(dot)in, pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #6372: Error while creating database with fsync parameter as on incase of CIFS
Date: 2012-01-02 20:28:33
Message-ID: 1476.1325536113@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs

Magnus Hagander <magnus(at)hagander(dot)net> writes:
> On Mon, Jan 2, 2012 at 21:14, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>> I'm wondering what's your basis for asserting we don't support CIFS in
>> general? It's probably not terribly bulletproof, but any worse than NFS?

> Yes, it is a lot worse than NFS from experience. I can't find a
> reference to it anywhere now, but IIRC there are bigger issues - with
> blocksizes, with syncing not properly, with write ordering.

Hmm. I searched the list archives and couldn't find any previous
discussion of such things, but that may just prove that no one thinks
it's worth attempting.

Anyway the immediate question is which errnos are reasonable for copydir
to ignore. Just looking at the standard's description of fsync's error
conditions:

The fsync() function shall fail if:
[EBADF]
The fildes argument is not a valid descriptor.
[EINTR]
The fsync() function was interrupted by a signal.
[EINVAL]
The fildes argument does not refer to a file on which this operation is possible.
[EIO]
An I/O error occurred while reading from or writing to the file system.

it seems like EINVAL is a considerably more reasonable thing to return
than EBADF, if the filesystem is trying to tell you that it won't fsync
a directory. So I'm a bit surprised this question hasn't come up for
other filesystems.

regards, tom lane


From: Magnus Hagander <magnus(at)hagander(dot)net>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: anjali_524(at)yahoo(dot)co(dot)in, pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #6372: Error while creating database with fsync parameter as on incase of CIFS
Date: 2012-01-02 20:30:19
Message-ID: CABUevEx9emVqaZKXCXgVH7pTmj7UBvSmJ9CSRK7Fxg6yyK+mFw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs

On Mon, Jan 2, 2012 at 21:28, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Magnus Hagander <magnus(at)hagander(dot)net> writes:
>> On Mon, Jan 2, 2012 at 21:14, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>>> I'm wondering what's your basis for asserting we don't support CIFS in
>>> general?  It's probably not terribly bulletproof, but any worse than NFS?
>
>> Yes, it is a lot worse than NFS from experience. I can't find a
>> reference to it anywhere now, but IIRC there are bigger issues - with
>> blocksizes, with syncing not properly, with write ordering.
>
> Hmm.  I searched the list archives and couldn't find any previous
> discussion of such things, but that may just prove that no one thinks
> it's worth attempting.

Yeah, I don't think it was in our archives, it was somewhere else.

And as a disclaime r- it may have been about the win32 cifs *client*.
It was at the time just talking windows cifs client -> windows cifs
server.

> Anyway the immediate question is which errnos are reasonable for copydir
> to ignore.  Just looking at the standard's description of fsync's error
> conditions:
>
>        The fsync() function shall fail if:
>        [EBADF]
>        The fildes argument is not a valid descriptor.
>        [EINTR]
>        The fsync() function was interrupted by a signal.
>        [EINVAL]
>        The fildes argument does not refer to a file on which this operation is possible.
>        [EIO]
>        An I/O error occurred while reading from or writing to the file system.
>
> it seems like EINVAL is a considerably more reasonable thing to return
> than EBADF, if the filesystem is trying to tell you that it won't fsync
> a directory.  So I'm a bit surprised this question hasn't come up for
> other filesystems.

Agreed. But do we really want to accept this with fsync=on? It
basically means fsync=maybe, no?

--
 Magnus Hagander
 Me: http://www.hagander.net/
 Work: http://www.redpill-linpro.com/


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Magnus Hagander <magnus(at)hagander(dot)net>
Cc: anjali_524(at)yahoo(dot)co(dot)in, pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #6372: Error while creating database with fsync parameter as on incase of CIFS
Date: 2012-01-02 20:37:02
Message-ID: 1660.1325536622@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs

Magnus Hagander <magnus(at)hagander(dot)net> writes:
> On Mon, Jan 2, 2012 at 21:28, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>> it seems like EINVAL is a considerably more reasonable thing to return
>> than EBADF, if the filesystem is trying to tell you that it won't fsync
>> a directory. So I'm a bit surprised this question hasn't come up for
>> other filesystems.

> Agreed. But do we really want to accept this with fsync=on? It
> basically means fsync=maybe, no?

Well, given the number of cases that the code already ignores when
isdir is true, I don't think that argument holds much water at all.

However, I'm not real eager to change this just on the basis of the CIFS
case. If we find another filesystem that returns the same errno,
though, I would vote to change it.

regards, tom lane


From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Magnus Hagander <magnus(at)hagander(dot)net>, anjali_524 <anjali_524(at)yahoo(dot)co(dot)in>, Pg Bugs <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: BUG #6372: Error while creating database with fsync parameter as on incase of CIFS
Date: 2012-01-02 20:53:08
Message-ID: 1325537384-sup-6201@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs


Excerpts from Tom Lane's message of lun ene 02 17:28:33 -0300 2012:

> Anyway the immediate question is which errnos are reasonable for copydir
> to ignore. Just looking at the standard's description of fsync's error
> conditions:
>
> The fsync() function shall fail if:
> [EBADF]
> The fildes argument is not a valid descriptor.
> [EINTR]
> The fsync() function was interrupted by a signal.
> [EINVAL]
> The fildes argument does not refer to a file on which this operation is possible.
> [EIO]
> An I/O error occurred while reading from or writing to the file system.
>
> it seems like EINVAL is a considerably more reasonable thing to return
> than EBADF, if the filesystem is trying to tell you that it won't fsync
> a directory. So I'm a bit surprised this question hasn't come up for
> other filesystems.

Probably because other filesystems do allow you to fsync directories.
In fact for some cases they _require_ it ... remember the fiasco when
MTA writers were told that they needed to fsync their queue dirs in
order for all queued email to persist?

--
Álvaro Herrera <alvherre(at)commandprompt(dot)com>
The PostgreSQL Company - Command Prompt, Inc.
PostgreSQL Replication, Consulting, Custom Development, 24x7 support


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
Cc: Magnus Hagander <magnus(at)hagander(dot)net>, anjali_524 <anjali_524(at)yahoo(dot)co(dot)in>, Pg Bugs <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: BUG #6372: Error while creating database with fsync parameter as on incase of CIFS
Date: 2012-01-02 21:00:19
Message-ID: 2113.1325538019@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs

Alvaro Herrera <alvherre(at)commandprompt(dot)com> writes:
> Excerpts from Tom Lane's message of lun ene 02 17:28:33 -0300 2012:
>> it seems like EINVAL is a considerably more reasonable thing to return
>> than EBADF, if the filesystem is trying to tell you that it won't fsync
>> a directory. So I'm a bit surprised this question hasn't come up for
>> other filesystems.

> Probably because other filesystems do allow you to fsync directories.
> In fact for some cases they _require_ it ... remember the fiasco when
> MTA writers were told that they needed to fsync their queue dirs in
> order for all queued email to persist?

Yeah, the long and the short of it is that if the filesystem won't
accept an fsync on a directory, we have to assume that it doesn't need
it and will manage metadata persistence safely without prodding.

The only real question here is whether an EINVAL could mean something
besides "fsync on directory is not accepted". If there are any
scenarios where it represents a transient/fixable error, then we'd
want to report it. It's far from clear to me that there are any
though. What it could mean in general is not at issue, because we
know the target is a directory that we just created moments before.

regards, tom lane


From: Anjali Arora <anjali_524(at)yahoo(dot)co(dot)in>
To: Magnus Hagander <magnus(at)hagander(dot)net>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "pgsql-bugs(at)postgresql(dot)org" <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: BUG #6372: Error while creating database with fsync parameter as on incase of CIFS
Date: 2012-01-06 17:49:41
Message-ID: 1325872181.2644.YahooMailNeo@web95516.mail.in.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs

Hi Tom,
 
Thanks for the solution. CIFS worked with fsync flag by ingnoring EINVAL in copydir.c.
 
I tested fsync with 8.2.2 version of PostgreSQL, it worked fine without EINVAL patch. I wanted to know is something changed in version 9.0.4 of postgreSQL.
 
As fsync flag was not working with PostgreSQL version 9.0.4 without applying the patch.
 
Regards,
Anjali

________________________________
From: Magnus Hagander <magnus(at)hagander(dot)net>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: anjali_524(at)yahoo(dot)co(dot)in; pgsql-bugs(at)postgresql(dot)org
Sent: Tuesday, 3 January 2012 2:00 AM
Subject: Re: [BUGS] BUG #6372: Error while creating database with fsync parameter as on incase of CIFS

On Mon, Jan 2, 2012 at 21:28, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Magnus Hagander <magnus(at)hagander(dot)net> writes:
>> On Mon, Jan 2, 2012 at 21:14, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>>> I'm wondering what's your basis for asserting we don't support CIFS in
>>> general?  It's probably not terribly bulletproof, but any worse than NFS?
>
>> Yes, it is a lot worse than NFS from experience. I can't find a
>> reference to it anywhere now, but IIRC there are bigger issues - with
>> blocksizes, with syncing not properly, with write ordering.
>
> Hmm.  I searched the list archives and couldn't find any previous
> discussion of such things, but that may just prove that no one thinks
> it's worth attempting.

Yeah, I don't think it was in our archives, it was somewhere else.

And as a disclaime r- it may have been about the win32 cifs *client*.
It was at the time just talking windows cifs client -> windows cifs
server.

> Anyway the immediate question is which errnos are reasonable for copydir
> to ignore.  Just looking at the standard's description of fsync's error
> conditions:
>
>        The fsync() function shall fail if:
>        [EBADF]
>        The fildes argument is not a valid descriptor.
>        [EINTR]
>        The fsync() function was interrupted by a signal.
>        [EINVAL]
>        The fildes argument does not refer to a file on which this operation is possible.
>        [EIO]
>        An I/O error occurred while reading from or writing to the file system.
>
> it seems like EINVAL is a considerably more reasonable thing to return
> than EBADF, if the filesystem is trying to tell you that it won't fsync
> a directory.  So I'm a bit surprised this question hasn't come up for
> other filesystems.

Agreed. But do we really want to accept this with fsync=on? It
basically means fsync=maybe, no?

--
 Magnus Hagander
 Me: http://www.hagander.net/
 Work: http://www.redpill-linpro.com/


From: Anjali Arora <anjali_524(at)yahoo(dot)co(dot)in>
To: Magnus Hagander <magnus(at)hagander(dot)net>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "pgsql-bugs(at)postgresql(dot)org" <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: BUG #6372: Error while creating database with fsync parameter as on incase of CIFS
Date: 2012-01-09 05:13:55
Message-ID: 1326086035.43672.YahooMailNeo@web95511.mail.in.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs

Hi Tom,
 
Thanks for the solution. CIFS worked with fsync flag by ingnoring EINVAL in copydir.c.
 
I tested fsync with 8.2.2 version of PostgreSQL, it worked fine without EINVAL patch. I wanted to know is something changed in version 9.0.4 of postgreSQL.
 
As fsync flag was not working with PostgreSQL version 9.0.4 without applying the patch.
 
Regards,
Anjali

________________________________
From: Magnus Hagander <magnus(at)hagander(dot)net>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: anjali_524(at)yahoo(dot)co(dot)in; pgsql-bugs(at)postgresql(dot)org
Sent: Tuesday, 3 January 2012 2:00 AM
Subject: Re: [BUGS] BUG #6372: Error while creating database with fsync parameter as on incase of CIFS

On Mon, Jan 2, 2012 at 21:28, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Magnus Hagander <magnus(at)hagander(dot)net> writes:
>> On Mon, Jan 2, 2012 at 21:14, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>>> I'm wondering what's your basis for asserting we don't support CIFS in
>>> general?  It's probably not terribly bulletproof, but any worse than NFS?
>
>> Yes, it is a lot worse than NFS from experience. I can't find a
>> reference to it anywhere now, but IIRC there are bigger issues - with
>> blocksizes, with syncing not properly, with write ordering.
>
> Hmm.  I searched the list archives and couldn't find any previous
> discussion of such things, but that may just prove that no one thinks
> it's worth attempting.

Yeah, I don't think it was in our archives, it was somewhere else.

And as a disclaime r- it may have been about the win32 cifs *client*.
It was at the time just talking windows cifs client -> windows cifs
server.

> Anyway the immediate question is which errnos are reasonable for copydir
> to ignore.  Just looking at the standard's description of fsync's error
> conditions:
>
>        The fsync() function shall fail if:
>        [EBADF]
>        The fildes argument is not a valid descriptor.
>        [EINTR]
>        The fsync() function was interrupted by a signal.
>        [EINVAL]
>        The fildes argument does not refer to a file on which this operation is possible.
>        [EIO]
>        An I/O error occurred while reading from or writing to the file system.
>
> it seems like EINVAL is a considerably more reasonable thing to return
> than EBADF, if the filesystem is trying to tell you that it won't fsync
> a directory.  So I'm a bit surprised this question hasn't come up for
> other filesystems.

Agreed. But do we really want to accept this with fsync=on? It
basically means fsync=maybe, no?

--
 Magnus Hagander
 Me: http://www.hagander.net/
 Work: http://www.redpill-linpro.com/


From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Alvaro Herrera <alvherre(at)commandprompt(dot)com>, Magnus Hagander <magnus(at)hagander(dot)net>, anjali_524 <anjali_524(at)yahoo(dot)co(dot)in>, Pg Bugs <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: BUG #6372: Error while creating database with fsync parameter as on incase of CIFS
Date: 2012-08-27 02:19:40
Message-ID: 20120827021940.GB28780@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs

On Mon, Jan 2, 2012 at 04:00:19PM -0500, Tom Lane wrote:
> Alvaro Herrera <alvherre(at)commandprompt(dot)com> writes:
> > Excerpts from Tom Lane's message of lun ene 02 17:28:33 -0300 2012:
> >> it seems like EINVAL is a considerably more reasonable thing to return
> >> than EBADF, if the filesystem is trying to tell you that it won't fsync
> >> a directory. So I'm a bit surprised this question hasn't come up for
> >> other filesystems.
>
> > Probably because other filesystems do allow you to fsync directories.
> > In fact for some cases they _require_ it ... remember the fiasco when
> > MTA writers were told that they needed to fsync their queue dirs in
> > order for all queued email to persist?
>
> Yeah, the long and the short of it is that if the filesystem won't
> accept an fsync on a directory, we have to assume that it doesn't need
> it and will manage metadata persistence safely without prodding.
>
> The only real question here is whether an EINVAL could mean something
> besides "fsync on directory is not accepted". If there are any
> scenarios where it represents a transient/fixable error, then we'd
> want to report it. It's far from clear to me that there are any
> though. What it could mean in general is not at issue, because we
> know the target is a directory that we just created moments before.

I assume this never got resolved. Should it be changed to ignore
EINVAL?

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ It's impossible for everything to be true. +