Re: pread() and pwrite()

From: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>
To: Thomas Munro <thomas(dot)munro(at)enterprisedb(dot)com>
Cc: Jesper Pedersen <jesper(dot)pedersen(at)redhat(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Magnus Hagander <magnus(at)hagander(dot)net>, Oskari Saarenmaa <os(at)ohmu(dot)fi>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>, Tobias Oberstein <tobias(dot)oberstein(at)gmail(dot)com>
Subject: Re: pread() and pwrite()
Date: 2018-11-05 15:59:18
Message-ID: 20181105155918.jg36uj4rtnxwqtzt@alvherre.pgsql
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 2018-Nov-04, Thomas Munro wrote:

> Here's a patch to add Windows support by supplying
> src/backend/port/win32/pread.c. Thoughts?

Hmm, so how easy is to detect that somebody runs read/write on fds where
pread/pwrite have occurred? I guess for data files it's easy to detect
since you'd quickly end up with corrupted files, but what about other
kinds of files? I wonder if we should be worrying about using this
interface somewhere other than fd.c and forgetting about the limitation.
Say, what happens if we patch some place in xlog.c after this patch gets
in, using write() instead of pwrite()?

I suppose the safest approach is to use lseek (or whatever) to fix up
the position after the pread/pwrite -- but we don't want to pay the
price on an additional syscall. Are there any other options? Is there
a way to prevent read/write from being used on a file handle?

--
Álvaro Herrera https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bossart, Nathan 2018-11-05 16:00:19 Re: New vacuum option to do only freezing
Previous Message Dmitry Dolgov 2018-11-05 15:19:07 Re: Flexible permissions for REFRESH MATERIALIZED VIEW