Thread: pgsql-server: Per previous discussions, get rid of use of sync(2) in

pgsql-server: Per previous discussions, get rid of use of sync(2) in

From
tgl@svr1.postgresql.org (Tom Lane)
Date:
Log Message:
-----------
Per previous discussions, get rid of use of sync(2) in favor of
explicitly fsync'ing every (non-temp) file we have written since the
last checkpoint.  In the vast majority of cases, the burden of the
fsyncs should fall on the bgwriter process not on backends.  (To this
end, we assume that an fsync issued by the bgwriter will force out
blocks written to the same file by other processes using other file
descriptors.  Anyone have a problem with that?)  This makes the world
safe for WIN32, which ain't even got sync(2), and really makes the world
safe for Unixen as well, because sync(2) never had the semantics we need:
it offers no way to wait for the requested I/O to finish.

Along the way, fix a bug I recently introduced in xlog recovery:
file truncation replay failed to clear bufmgr buffers for the dropped
blocks, which could result in 'PANIC:  heap_delete_redo: no block'
later on in xlog replay.

Modified Files:
--------------
    pgsql-server/src/backend/access/transam:
        clog.c (r1.19 -> r1.20)

(http://developer.postgresql.org/cvsweb.cgi/pgsql-server/src/backend/access/transam/clog.c.diff?r1=1.19&r2=1.20)
        slru.c (r1.15 -> r1.16)

(http://developer.postgresql.org/cvsweb.cgi/pgsql-server/src/backend/access/transam/slru.c.diff?r1=1.15&r2=1.16)
    pgsql-server/src/backend/postmaster:
        bgwriter.c (r1.1 -> r1.2)
        (http://developer.postgresql.org/cvsweb.cgi/pgsql-server/src/backend/postmaster/bgwriter.c.diff?r1=1.1&r2=1.2)
    pgsql-server/src/backend/storage/buffer:
        bufmgr.c (r1.166 -> r1.167)

(http://developer.postgresql.org/cvsweb.cgi/pgsql-server/src/backend/storage/buffer/bufmgr.c.diff?r1=1.166&r2=1.167)
    pgsql-server/src/backend/storage/file:
        fd.c (r1.108 -> r1.109)
        (http://developer.postgresql.org/cvsweb.cgi/pgsql-server/src/backend/storage/file/fd.c.diff?r1=1.108&r2=1.109)
    pgsql-server/src/backend/storage/smgr:
        md.c (r1.104 -> r1.105)
        (http://developer.postgresql.org/cvsweb.cgi/pgsql-server/src/backend/storage/smgr/md.c.diff?r1=1.104&r2=1.105)
        smgr.c (r1.70 -> r1.71)
        (http://developer.postgresql.org/cvsweb.cgi/pgsql-server/src/backend/storage/smgr/smgr.c.diff?r1=1.70&r2=1.71)
    pgsql-server/src/include/access:
        slru.h (r1.5 -> r1.6)
        (http://developer.postgresql.org/cvsweb.cgi/pgsql-server/src/include/access/slru.h.diff?r1=1.5&r2=1.6)
    pgsql-server/src/include/postmaster:
        bgwriter.h (r1.1 -> r1.2)
        (http://developer.postgresql.org/cvsweb.cgi/pgsql-server/src/include/postmaster/bgwriter.h.diff?r1=1.1&r2=1.2)
    pgsql-server/src/include/storage:
        bufmgr.h (r1.80 -> r1.81)
        (http://developer.postgresql.org/cvsweb.cgi/pgsql-server/src/include/storage/bufmgr.h.diff?r1=1.80&r2=1.81)
        fd.h (r1.44 -> r1.45)
        (http://developer.postgresql.org/cvsweb.cgi/pgsql-server/src/include/storage/fd.h.diff?r1=1.44&r2=1.45)
        lwlock.h (r1.10 -> r1.11)
        (http://developer.postgresql.org/cvsweb.cgi/pgsql-server/src/include/storage/lwlock.h.diff?r1=1.10&r2=1.11)
        smgr.h (r1.41 -> r1.42)
        (http://developer.postgresql.org/cvsweb.cgi/pgsql-server/src/include/storage/smgr.h.diff?r1=1.41&r2=1.42)