Skip site navigation (1) Skip section navigation (2)

Re: pgsql: Tune GetSnapshotData() during Hot Standby by avoiding loop

From: Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>
To: Simon Riggs <sriggs(at)postgresql(dot)org>
Cc: pgsql-committers(at)postgresql(dot)org
Subject: Re: pgsql: Tune GetSnapshotData() during Hot Standby by avoiding loop
Date: 2010-04-19 07:36:17
Message-ID: 4BCC07F1.6040405@enterprisedb.com (view raw or flat)
Thread:
Lists: pgsql-committerspgsql-hackers
Simon Riggs wrote:
> Log Message:
> -----------
> Tune GetSnapshotData() during Hot Standby by avoiding loop
> through normal backends. Makes code clearer also, since we
> avoid various Assert()s. Performance of snapshots taken
> during recovery no longer depends upon number of read-only
> backends.

I think there's a little race condition there.
snapshot->takenDuringRecovery is set before acquiring ProcArrayLock, so
it's possible that by the time we acquire the lock, we're no longer in
recovery. So this can happen:

1. Backend A starts to take a snapshot, while we're still in recovery.
takenDuringRecovery is assigned true.
2. Recovery ends, and a normal transaction X begins in backend B.
3. A skips scanning ProcArray because takenDuringRecovery is true.

The snapshot doesn't include X, so any changes done in that transaction
will not be visible to the snapshot while the transaction is still
running, but will be after it commits.

Of course, it's highly improbable for 2. to happen, but it's there.

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

In response to

Responses

pgsql-hackers by date

Next:From: Simon RiggsDate: 2010-04-19 08:05:32
Subject: Re: [COMMITTERS] pgsql: Tune GetSnapshotData() during Hot Standby by avoiding loop
Previous:From: Nikhil SontakkeDate: 2010-04-19 06:34:13
Subject: row estimation off the mark when generate_series calls are involved

pgsql-committers by date

Next:From: Simon RiggsDate: 2010-04-19 08:05:32
Subject: Re: [COMMITTERS] pgsql: Tune GetSnapshotData() during Hot Standby by avoiding loop
Previous:From: User MkzDate: 2010-04-19 07:08:31
Subject: pgbouncer - pgbouncer: Dont let logging change errno.

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group