Re: BUG #15636: PostgreSQL 11.1 pg_basebackup backup to a CIFS destination throws fsync error at end of backup

From: Thomas Munro <thomas(dot)munro(at)enterprisedb(dot)com>
To: jk7255(at)gmail(dot)com, PostgreSQL mailing lists <pgsql-bugs(at)lists(dot)postgresql(dot)org>
Subject: Re: BUG #15636: PostgreSQL 11.1 pg_basebackup backup to a CIFS destination throws fsync error at end of backup
Date: 2019-02-14 22:06:18
Message-ID: CAEepm=1VJQ82z2BYxMLWJHJ3SPx7ckGwZUgRYPAoa=5btT1Fxg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Fri, Feb 15, 2019 at 10:15 AM PG Bug reporting form
<noreply(at)postgresql(dot)org> wrote:
> pg_basebackup: could not fsync file
> "/cifs/backups/<backupDirectoryName>/basebkp/base/1": Invalid argument
> pg_basebackup: could not fsync file

Hmm, it looks like your system gives EINVAL when you try to fsync a
directory. Perhaps we should teach fsync__fname() about that here:

/*
* Some OSes don't allow us to fsync directories at all, so we
can ignore
* those errors. Anything else needs to be reported.
*/
if (returncode != 0 && !(isdir && errno == EBADF))
{
fprintf(stderr, _("%s: could not fsync file \"%s\": %s\n"),
progname, fname, strerror(errno));
(void) close(fd);
return -1;
}

EINVAL actually makes more sense to me than EBADF for a filesystem
that can't fsync directories. From POSIX: EINVAL = "The fildes
argument does not refer to a file on which this operation is
possible." vs EBADF "The fildes argument is not a valid descriptor."
It *is* a valid descriptor, it's just not a valid operation
(apparently).

Quick googling on the topic tells me that CIFS directory operations
are "synchronous", so fsync'ing isn't necessary. However, they only
made it silently do nothing in a recent version:

https://github.com/torvalds/linux/commit/6e70c267e68d77679534dcf4aaf84e66f2cf1425

Presumably before that you get EINVAL because there is no handler
registered. The commit message even mentions that this was breaking
stuff like us.

--
Thomas Munro
http://www.enterprisedb.com

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2019-02-14 22:26:55 Re: Segmentation Fault in logical decoding get/peek API
Previous Message PG Bug reporting form 2019-02-14 20:40:07 BUG #15636: PostgreSQL 11.1 pg_basebackup backup to a CIFS destination throws fsync error at end of backup