fd.c: flush data problems on osx

From: Stas Kelvich <s(dot)kelvich(at)postgrespro(dot)ru>
To: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: fd.c: flush data problems on osx
Date: 2016-03-17 17:09:53
Message-ID: 5CF3DFCC-26FB-4162-8933-DD2A6FE3B27A@postgrespro.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi

Current implementation of pg_flush_data when called with zero offset and zero nbytes is assumed to flush all file. In osx it uses mmap with these arguments, but according to man:

"[EINVAL] The len argument was negative or zero. Historically, the system call would not return an
error if the argument was zero. See other potential additional restrictions in the COMPAT-
IBILITY section below."

so it is generate a lot of warnings:

"WARNING: could not mmap while flushing dirty data: Invalid argument"

Call to pg_flush_data with zero offset and nbytes happens when replica starts from base backup and fsync=on. TAP test to reproduce is attached.

One possible solution for that is just fallback to pg_fdatasync in case when offset = nbytes = 0.

Also there are no default ifdef inside this function, is there any check that will guarantee that pg_flush_data will not end up with empty body on some platform?

---
Stas Kelvich
Postgres Professional: http://www.postgrespro.com
Russian Postgres Company

Attachment Content-Type Size
000_flush_data.pl text/x-perl-script 584 bytes
flushdata.patch application/octet-stream 590 bytes

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2016-03-17 17:15:43 Re: Using quicksort for every external sort run
Previous Message Tom Lane 2016-03-17 16:59:05 Re: Re: Add generate_series(date,date) and generate_series(date,date,integer)