Re: Synchronization primitives (Was: Re: An example of bugs for Hot Standby)

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>
Cc: Andres Freund <andres(at)anarazel(dot)de>, Simon Riggs <simon(at)2ndquadrant(dot)com>, pgsql-hackers(at)postgresql(dot)org, Hiroyuki Yamada <yamada(at)kokolink(dot)net>
Subject: Re: Synchronization primitives (Was: Re: An example of bugs for Hot Standby)
Date: 2010-01-20 18:16:05
Message-ID: 16135.1264011365@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com> writes:
> 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);
> }

I trust there's a CHECK_FOR_INTERRUPTS in there ...

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

Maybe. The lock, the variable, the comparison operation, and the sleep
time all seem rather specific to each application. Not sure that it'd
really buy much to try to turn it into a generic subroutine.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Simon Riggs 2010-01-20 18:45:07 Re: Synchronization primitives (Was: Re: An example of bugs for Hot Standby)
Previous Message Mark Wong 2010-01-20 18:02:37 Re: MonetDB test says that PostgreSQL often has errors or missing results