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 1g70BP-0005Xw-6M for pgsql-general@arkaria.postgresql.org; Mon, 01 Oct 2018 15:32:27 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1g70BK-0002RI-Bg for pgsql-general@arkaria.postgresql.org; Mon, 01 Oct 2018 15:32:22 +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 1g70BJ-0002RB-5Y for pgsql-general@lists.postgresql.org; Mon, 01 Oct 2018 15:32:22 +0000 Received: from out3-smtp.messagingengine.com ([66.111.4.27]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1g70BE-0001j8-4x for pgsql-general@postgresql.org; Mon, 01 Oct 2018 15:32:20 +0000 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id 36F4021E13; Mon, 1 Oct 2018 11:32:14 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Mon, 01 Oct 2018 11:32:14 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=anarazel.de; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-sender :x-me-sender:x-sasl-enc; s=fm2; bh=hl50Wm9gwrkBCPm5DVbQWMNAUMPRG 3APmKyjGO3AZG4=; b=vOlo0eDuflp8W0b2VXWHxqSbRC2VqLM084pIOOoJo47o3 VN9FlpT44u87UgBOy3GIwxXSyqTeVkTkaTfUZZOovjewP/bJljTVw3hiunlsPt6w Uq98A1KVAhyv/xlorV0nSqAHjXzVi1j2tAIoS1gvTs68SvkuQe6QmTgV+f3ApdH2 OXecRi8yqHqTjxogPErYvkMGY5q3oYdm5QAWCjYSFju6wC29slN8kHvKgcBJLT9i hIVZCDFea8XrRSvGLi8suKPXbA3MeKYfxQA6oDd13i2Y6IqtdXaeZb0vs8OgZSzx aH4gQSN8tp3kugNuvma10M14DGmTsn7GQXdUaoReQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; bh=hl50Wm 9gwrkBCPm5DVbQWMNAUMPRG3APmKyjGO3AZG4=; b=L6hJS5Pj6g53bwM4lZU+pz q/zTbNCNsrRKrMR4gni3uFCvB0MjKmvBmZxOm6o3bAnAl0XRo9faTkvXHlVo7jQY 7v/EEzbK+wlNAFxD5UbG+/RmRQdzymYniFAu30+EWUPJiroZHITq7Era2DVo1jPu ly+zGkxwcqLW4lorQE8PkBCdCq5TXRTtaIvKbAieOhO9cXAMdMJiNeZzdWoSNSNT g0kfrta6027+3KhsJdhl4MmdN+/h0/kxtLIunJKtBSBrkaebE72W8LaVax8+csIq kHToX6fs5+hP63TS7rk77ZaGCWwV4j46j4BnZgLhn8EDIFJ6CHRkOC/dyuoi0bNg == X-ME-Sender: X-ME-Proxy: Received: from intern.anarazel.de (c-98-210-140-171.hsd1.ca.comcast.net [98.210.140.171]) by mail.messagingengine.com (Postfix) with ESMTPA id 7325B102A0; Mon, 1 Oct 2018 11:32:13 -0400 (EDT) Date: Mon, 1 Oct 2018 08:32:11 -0700 From: Andres Freund To: Torsten =?utf-8?Q?F=C3=B6rtsch?= Cc: PostgreSQL mailing lists Subject: Re: backend_xmin in pg_stat_replication Message-ID: <20181001153211.wnsa57kwrfufrd2m@alap3.anarazel.de> References: MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Hi, On 2018-10-01 12:20:26 +0200, Torsten Förtsch wrote: > if I understand it correctly, backend_xmin in pg_stat_replication is the > xmin that's reported back by hot_standby_feedback. Given there are no > long-running transactions on the replica, I presume that value should be > pretty close to the xmin field of any recent snapshots on the master. This > is true for all my databases but one: > > select application_name, > txid_snapshot_xmin(txid_current_snapshot()), > backend_xmin::TEXT::BIGINT, > > txid_snapshot_xmin(txid_current_snapshot())-backend_xmin::TEXT::BIGINT > from pg_stat_replication; > > application_name | txid_snapshot_xmin | backend_xmin | ?column? > ------------------+--------------------+--------------+------------ > xxxxxxxxxx | 6 957 042 833 | 2 662 075 435 | 4 294 967 398 I don't think the calculation you're doing here is correct. backend_xmin is an xid (max 2^32-1), whereas txid_snapshot_xmin returns an xid *with* epoch (max 2^64-1). What you're measuring here is simply the fact that the xid counter has wrapped around. Greetings, Andres Freund