pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Heikki Linnakangas <heikki.linnakangas@enterprisedb.com>
To: Andres Freund <andres@anarazel.de>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Simon Riggs <simon@2ndquadrant.com>
Cc: pgsql-hackers@postgresql.org, Hiroyuki Yamada <yamada@kokolink.net>
Subject: Synchronization primitives (Was: Re: An example of bugs for Hot Standby)
Date: Wed, 20 Jan 2010 20:00:33 +0200
Message-ID: <4B5744C1.40806@enterprisedb.com> (raw)
In-Reply-To: <201001201841.15760.andres@anarazel.de>
References: <200912151111.AA00168@silver.kokolink.net>
	<201001201740.22069.andres@anarazel.de>
	<14578.1264006776@sss.pgh.pa.us>
	<201001201841.15760.andres@anarazel.de>

Andres Freund wrote:
> On Wednesday 20 January 2010 17:59:36 Tom Lane wrote:
>> Andres Freund <andres@anarazel.de> writes:
>>> I realize its way too late in the cycle for that, but why dont we start
>>> using some library for easy cross platform atomic ops?
>> (1) there probably isn't one that does exactly what we want, works
>> everywhere, and has the right license;
>> (2) what actual gain would we get?  We've already done the work.
> That there might be some other instructions were interested in?
> Like really atomic increment?

This reminds me of something I've been pondering for some time:

Streaming Replication introduces a few places with a polling pattern
like this (in pseudocode):

while()
{
  /* Check if variable in shared has advanced beoynd X */
  SpinLockAcquire()
  localvar = sharedvar;
  SpinLockRelease()
  if (localvar > X)
    break;

  /* Not yet. Sleep
  pg_usleep(100);
}

For example, startup process polls like that to wait for walreceiver to
write & flush new WAL to be replayed. And in master, walsender polls
like that for new WAL to be generated, so that it can be sent to
standby. Hot standby also has a polling loop where it waits for a
transaction a transaction to die, though I'm not sure if that can be fit
into the same model.

That's OK for asynchronous replication, but unacceptable for synchronous
mode.

It would be nice to have a new synchronization primitive for that.

-- 
  Heikki Linnakangas
  EnterpriseDB   http://www.enterprisedb.com



view thread (8+ messages)  latest in thread

Message-ID: <4B5744C1.40806@enterprisedb.com>
Permalink:  ../4B5744C1.40806@enterprisedb.com/
Also on:    postgresql.org/message-id/4B5744C1.40806@enterprisedb.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: heikki.linnakangas@enterprisedb.com, andres@anarazel.de, tgl@sss.pgh.pa.us, simon@2ndquadrant.com, yamada@kokolink.net
  Subject: Re: Synchronization primitives (Was: Re: An example of bugs for Hot Standby)
  In-Reply-To: <4B5744C1.40806@enterprisedb.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox