On Fri, Feb 15, 2019 at 10:15 AM PG Bug reporting form
<noreply@postgresql.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