Received: from magus.postgresql.org ([87.238.57.229]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TJd6k-00022n-T7 for pgsql-bugs@postgresql.org; Thu, 04 Oct 2012 04:32:22 +0000 Received: from [2404:130:0:10::40:2] (helo=mail.catalyst.net.nz) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TJd6i-0002tB-7P for pgsql-bugs@postgresql.org; Thu, 04 Oct 2012 04:32:22 +0000 Received: from localhost (localhost [127.0.0.1]) by mail.catalyst.net.nz (Postfix) with ESMTP id 87D9C328E3 for ; Thu, 4 Oct 2012 17:32:14 +1300 (NZDT) X-Virus-Scanned: Debian amavisd-new at catalyst.net.nz Received: from mail.catalyst.net.nz ([127.0.0.1]) by localhost (bertrand.catalyst.net.nz [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id gG1cgiv14SCH for ; Thu, 4 Oct 2012 17:32:13 +1300 (NZDT) Received: from [IPv6:2404:130:0:1000:9158:9811:9a6e:d160] (unknown [IPv6:2404:130:0:1000:9158:9811:9a6e:d160]) (Authenticated sender: mark.kirkwood) by mail.catalyst.net.nz (Postfix) with ESMTPSA id D55673263D for ; Thu, 4 Oct 2012 17:32:13 +1300 (NZDT) Message-ID: <506D114D.1050803@catalyst.net.nz> Date: Thu, 04 Oct 2012 17:32:13 +1300 From: Mark Kirkwood User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:15.0) Gecko/20120912 Thunderbird/15.0.1 MIME-Version: 1.0 To: "pgsql-bugs@postgresql.org" Subject: Pg_stat_replication shows sync standby with flush location behind primary in 9.1.5 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Host-Lookup-Failed: Reverse DNS lookup failed for 2404:130:0:10::40:2 (failed) X-Pg-Spam-Score: -1.1 (-) X-Archive-Number: 201210/30 X-Sequence-Number: 34330 I am seeing the situation where the reported flush location for the sync standby (standby1 below) is *behind* the reported current xlog location of the primary. This is Postgres 9.1.5 , and I was under the impression that transactions initiated on the master do not commit until the corresponding wal is flushed on the sync standby. Now the standby is definitely working in sync mode, because stopping it halts all write transactions on the primary (sync_standby_names contains only standby1). So is the reported lag in flush location merely an artifact of timing in the query, or is there something else going on? [1] db=# SELECT application_name,pg_current_xlog_location(),sent_location,write_location,flush_location,replay_location,sync_priority,state FROM pg_stat_replication where replay_location is not null; application_name | pg_current_xlog_location | sent_location | write_location | flush_location | replay_location | sync_priority | state ------------------+--------------------------+---------------+----------------+----------------+-----------------+---------------+----------- standby1 | E/254909E0 | E/25490000 | E/2548C3B8 | E/2548C3B8 | E/25476DE0 | 1 | streaming <=== standby2 | E/254909E0 | E/2548C3B8 | E/25476DE0 | E/25476DE0 | E/254724C0 | 0 | streaming standby3 | E/254909E0 | E/254909E0 | E/25476DE0 | E/25476DE0 | E/254724C0 | 0 | streaming standby4 | E/254909E0 | E/25490000 | E/2548C3B8 | E/25476DE0 | E/25476DE0 | 0 | streaming standby5 | E/254909E0 | E/25490000 | E/25476DE0 | E/25476DE0 | E/254724C0 | 0 | streaming (5 rows) Cheers Mark [1] Looking at the code for pg_stat_replication, it appears to take the sync rep lock while reporting, so in theory should be exactly right...I should perhaps check what pg_current_xlog_location does...