Re: [PERFORM] Cpu usage 100% on slave. s_lock problem.

From: Andres Freund <andres(at)2ndquadrant(dot)com>
To: Ants Aasma <ants(at)cybertec(dot)at>
Cc: Heikki Linnakangas <hlinnakangas(at)vmware(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, Merlin Moncure <mmoncure(at)gmail(dot)com>, Дмитрий Дегтярёв <degtyaryov(at)gmail(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [PERFORM] Cpu usage 100% on slave. s_lock problem.
Date: 2013-10-01 11:35:43
Message-ID: 20131001113543.GH2670970@alap2.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 2013-10-01 14:31:11 +0300, Ants Aasma wrote:
> >> The correct way to think of this is
> >> that StartupXLOG() does a bunch of state modifications and then
> >> advertises the fact that it's done by setting
> >> xlogctl->SharedRecoveryInProgress = false; The state modifications
> >> should better be visible to anyone seeing that last write, so you need
> >> one write barrier between the state modifications and setting the
> >> flag.
> >
> > SpinLockAcquire() should provide that.
>
> Yes. It's notable that in this case it's a matter of correctness that
> the global state modifications do *not* share the critical section
> with the flag update. Otherwise the flag update may become visible
> before the state updates.

I think we're currently essentially assuming that not only
SpinLockAcquire() is a barrier but also that SpinLockRelease() is
one... - which is actually far less likely to be true.

> >> So we need a read barrier somewhere *after* reading the flag in
> >> RecoveryInProgress() and reading the shared memory structures, and in
> >> theory a full barrier if we are going to be writing data. In practice
> >> x86 is covered thanks to it's memory model, Power is covered thanks to
> >> the control dependency and ARM would need a read barrier, but I don't
> >> think any real ARM CPU does speculative stores as that would be
> >> insane.
> >
> > Does there necessarily have to be a "visible" control dependency?
>
> Unfortunately no

That's what I thought :(

Greetings,

Andres Freund

--
Andres Freund http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Sameer Thakur 2013-10-01 12:32:51 Re: pg_stat_statements: calls under-estimation propagation
Previous Message Ants Aasma 2013-10-01 11:34:38 Re: Freezing without write I/O