On Fri, Mar 4, 2011 at 7:51 PM, Simon Riggs <si...@2ndquadrant.com> wrote: >> + if (walsnd->pid != 0 && >> + walsnd->sync_standby_priority > 0 && >> + (priority == 0 || >> + priority < walsnd->sync_standby_priority)) >> + { >> + priority = walsnd->sync_standby_priority; >> + syncWalSnd = walsnd; >> + } >> >> According to the code, the last named standby has highest priority. But the >> document says the opposite. > > Priority is a difficult word here since "1" is the highest priority. I > deliberately avoided using the word "highest" in the code for that > reason. > > The code above finds the lowest non-zero standby, which is correct as > documented.
Hmm.. that seems to find the highest standby. And, I could confirm that in my box. Please see the following. The priority (= 2) of synchronous standby (its sync_state is SYNC) is higher than that (= 1) of potential one (its sync_state is POTENTIAL). postgres=# SHOW synchronous_standby_names ; synchronous_standby_names --------------------------- one, two (1 row) postgres=# SELECT application_name, state, sync_priority, sync_state FROM pg_stat_replication; application_name | state | sync_priority | sync_state ------------------+-----------+---------------+------------ one | STREAMING | 1 | POTENTIAL two | STREAMING | 2 | SYNC (2 rows) Regards, -- Fujii Masao NIPPON TELEGRAPH AND TELEPHONE CORPORATION NTT Open Source Software Center -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers