global / super barriers (for checksums)

From: Andres Freund <andres(at)anarazel(dot)de>
To: Magnus Hagander <magnus(at)hagander(dot)net>, pgsql-hackers(at)postgresql(dot)org, Daniel Gustafsson <daniel(at)yesql(dot)se>
Subject: global / super barriers (for checksums)
Date: 2018-10-30 05:16:43
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers


Magnus cornered me at and asked me whether I could prototype
the "barriers" I'd been talking about in the online checksumming thread.

The problem there was to make sure that all processes, backends and
auxiliary processes have seen the new state of checksums being enabled,
and aren't currently in the process of writing a new page out.

The current prototype solves that by requiring a restart, but that
strikes me as a far too large hammer.

The attached patch introduces "global barriers" (name was invented in a
overcrowded hotel lounge, so ...), which allow to wait for such a change
to be absorbed by all backends.

I've only tested the code with gdb, but that seems to work:

p WaitForGlobalBarrier(EmitGlobalBarrier(GLOBBAR_CHECKSUM))

waits until all backends (including bgwriter, checkpointers, walwriters,
bgworkers, ...) have accepted interrupts at least once. Multiple such
requests are coalesced.

I decided to wait until interrupts are actually process, rather than
just the signal received, because that means the system is in a well
defined state. E.g. there's no pages currently being written out.

For the checksum enablement patch you'd do something like;


and after that you should be able to set it to a perstistent mode.

I chose to use procsignals to send the signals, a global uint64
globalBarrierGen, and per-backend barrierGen, barrierFlags, with the
latter keeping track which barriers have been requested. There likely
seem to be other usecases.

The patch definitely is in a prototype stage. At the very least it needs
a high-level comment somewhere, and some of the lower-level code needs
to be cleaned up.

One thing I wasn't happy about is how checksum internals have to absorb
barrier requests - that seems unavoidable, but I'd hope for something
more global than just BufferSync().



Andres Freund

Attachment Content-Type Size
0001-Use-procsignal_sigusr1_handler-for-all-shmem-connect.patch text/x-diff 2.0 KB
0002-Use-procsignal_sigusr1_handler-in-all-auxiliary-proc.patch text/x-diff 7.9 KB
0003-WIP-global-barriers.patch text/x-diff 13.7 KB


Browse pgsql-hackers by date

  From Date Subject
Next Message Tsunakawa, Takayuki 2018-10-30 06:24:48 RE: [PROPOSAL]a new data type 'bytea' for ECPG
Previous Message Haribabu Kommi 2018-10-30 05:11:22 Re: Resource cleanup callbacks for foreign data wrappers