Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fz0st-0001Ay-6x for pgsql-general@arkaria.postgresql.org; Sun, 09 Sep 2018 14:40:19 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fz0sr-0005Ow-3k for pgsql-general@arkaria.postgresql.org; Sun, 09 Sep 2018 14:40:17 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fz0iU-0004Hv-84 for pgsql-general@lists.postgresql.org; Sun, 09 Sep 2018 14:29:34 +0000 Received: from mail114-241.sinamail.sina.com.cn ([218.30.114.241]) by magus.postgresql.org with smtp (Exim 4.89) (envelope-from ) id 1fz0iK-0001eb-OD for pgsql-general@postgresql.org; Sun, 09 Sep 2018 14:29:31 +0000 Received: from unknown (HELO t460p)([180.172.118.221]) by sina.com with ESMTP id 5B952E35000017C8; Sun, 9 Sep 2018 22:29:09 +0800 (CST) X-Sender: wztdyl@sina.com X-Auth-ID: wztdyl@sina.com X-SMAIL-MID: 80503625952461 Message-ID: <4ffcd9e665cde2a7aaaaf55a3bc85145345e485c.camel@sina.com> Subject: how to know current xlog location on standby after primary is down From: magodo To: pgsql-general@postgresql.org Date: Sun, 09 Sep 2018 22:29:08 +0800 Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.28.5 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Hello, I'm working on a high availability project for PG(v9.6). Suppose I have a priamry-standby setup, I need to do promote once primary is down, but only when standby is as new as primary (before it is down). Therefore, I need a way to know the wal replay location on standby. I tried to set a hot standby, but it failed to run `pg_current_xlog_location()` on it; I also tried `pg_xlogdump` on standby, but it has following cavets: - hard to identify latest used wal segment, since there are some renamed reservations - sometimes `pg_xlogdump` will raise errors like: "pg_xlogdump: FATAL: error in WAL record at 0/9F88F0F8: record with incorrect prev- link 2020/20202020 at 0/9F88F130" So I want to know what is the correct way to do it. Thank you in advance!