Re: fd.c: flush data problems on osx

From: Andres Freund <andres(at)anarazel(dot)de>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Stas Kelvich <s(dot)kelvich(at)postgrespro(dot)ru>, Michael Paquier <michael(dot)paquier(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: fd.c: flush data problems on osx
Date: 2016-04-13 21:36:02
Message-ID: 20160413213602.w6b2nfplnxlgapf5@alap3.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 2016-04-13 17:21:01 -0400, Tom Lane wrote:
> I concluded that sharing the code would be more trouble than it's worth,
> because initdb.c's version of this is in fact not broken: it was never
> taught about mmap, and it doesn't need to be IMO, because it's not that
> performance-critical.

Agreed, there seems little immediate reason to go through additional
trouble. The issue of posix_fadvise(DONTNEED) dropping the cache seems
much less severe for initdb, than for the flushing patch (where it'd
obviously hurt).

It's probably good to unify the paths at some point in the future
though. We're lacking fsyncs in a bunch of relatively important paths
(WIP patch for most of them posted), and we end up needing fsync (and
probably the flushing logic) in the backend, initdb,
pg_basebackup/pg_recvlogical, pg_rewind and possibly some others that I
forgot about.

> I fixed the other things I complained about and pushed this.

Thanks for taking care of it!

> Please check to see that the committed patch resolves your original problem.

I looked through the commit, and I only have one very minor nitpick:
It might be good if
+ * We compile all alternatives that are supported on the current platform,
+ * to find portability problems more easily.
noted that we also fall through the approaches.

I'm not entirely sure what

+ /*
+ * Caution: do not call pg_flush_data with amount = 0, it could trash the
+ * file's seek position.
+ */
+ if (amount <= 0)
+ return;
+

is about?

- Andres

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2016-04-13 21:44:41 Re: fd.c: flush data problems on osx
Previous Message Tatsuo Ishii 2016-04-13 21:34:14 Re: Incomplete startup packet errors