Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ponrc-0003BA-TI for pgsql-general@arkaria.postgresql.org; Tue, 18 Apr 2023 16:07:28 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1ponra-0003eE-Q3 for pgsql-general@arkaria.postgresql.org; Tue, 18 Apr 2023 16:07:26 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ponra-0003e5-FN for pgsql-general@lists.postgresql.org; Tue, 18 Apr 2023 16:07:26 +0000 Received: from mail-ej1-x633.google.com ([2a00:1450:4864:20::633]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1ponrY-003f1G-8f for pgsql-general@lists.postgresql.org; Tue, 18 Apr 2023 16:07:25 +0000 Received: by mail-ej1-x633.google.com with SMTP id kt6so36381268ejb.0 for ; Tue, 18 Apr 2023 09:07:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec-at.20221208.gappssmtp.com; s=20221208; t=1681834043; x=1684426043; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:to:from:subject:message-id:from:to:cc:subject:date :message-id:reply-to; bh=10+au+EWO0IlfswnXWQ5qqf49cmEv0RLfOzuyaJLffI=; b=MkXi91pavyEgTUStKUbfnrl4LgHOiEQGnF0w+xzE6vTDGo6Edd2xeLPPWm3OhWADsn wn35f3F+ECtqFQyzq14yIYf4YL04MduciqD9kRUWUeFEWHtuMUhrIsPqGneXYzKA4SzG anQhpuPgxworXmBTMDlrgBpE4e+UoUhTFMVRQ9qHqCF2O4ezPG1wUmrQg/EiR3HQWISJ 0mjRZ/pE8eZy7LcuhhOPfBkdIK3R6MNnTOcXwjE2hEF9d7BojBsmuDXCPd9oLwW6ertq GmFcUBZrpxOHanXqZo3LUCJd2vSi8VuRAaFGKsI7UKvFEVNG+/JB6RsPYTNaL5OJYzSa ztlQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681834043; x=1684426043; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:to:from:subject:message-id:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=10+au+EWO0IlfswnXWQ5qqf49cmEv0RLfOzuyaJLffI=; b=A5KJ9SP7ZK7YMGZSxL6PoQI4bWd0qECp5DNy3kFriDS4/t8wLNs9LvxDlPeDpqr3IR Xlkva8WwB4CQoSowSVgKeQDZcZ+eoLgzC4sQsoSbZN0YF2TKT7x5uTov2s9aHAvIF44A /Uyn4bjkWqiYXwPv+hQNt4NWox7c70pBKtQPhAMPq9qDfSP93/ylsLsWCgrfh07CyMjR KCueQD/BvLgY25M6YsW8erPlWyJfJWg441C+Fg0DB1GGemw1yy67dgmukBOq6MGupUmq OWlC0ZEfyu4RR2lmzUOecQhkL7ffiIOqQyiB23MmoUBmosnsBYZCFSRq6zrVCZQEixev u4MQ== X-Gm-Message-State: AAQBX9clrqLWKYqHHCwOqkO4eXWXhPcRah0VZD/xe7VqsnrOtu8+8XMs /6hFTq73V12qE+XA7AOBk3Houw== X-Google-Smtp-Source: AKy350ab4k3dZvnrmpdp9KR8a/SP09bEC6xZ1SNh0PrC0vznPFucbm21d8Xf1CeKE/8GWiEK/WSAdg== X-Received: by 2002:a17:907:3e1c:b0:94f:3804:5cd6 with SMTP id hp28-20020a1709073e1c00b0094f38045cd6mr10355691ejc.66.1681834042867; Tue, 18 Apr 2023 09:07:22 -0700 (PDT) Received: from localhost.localdomain ([2001:871:5e:9c74:d0c:6fb0:317e:83cc]) by smtp.gmail.com with ESMTPSA id ud7-20020a170907c60700b0094ee700d8e4sm6571100ejc.44.2023.04.18.09.07.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Apr 2023 09:07:22 -0700 (PDT) Message-ID: Subject: Re: Logical Replication Sync Validation From: Laurenz Albe To: Robert =?ISO-8859-1?Q?Sj=F6blom?= , pgsql-general Date: Tue, 18 Apr 2023 18:07:21 +0200 In-Reply-To: <81990e48-56c3-21c5-7dcc-25725522c495@fortnox.se> References: <81990e48-56c3-21c5-7dcc-25725522c495@fortnox.se> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.46.4 (3.46.4-1.fc37) MIME-Version: 1.0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Tue, 2023-04-18 at 10:20 +0200, Robert Sj=C3=B6blom wrote: > At the moment where we would switch to pg15 being the primary/lead we=20 > will stop writes to pg10; at that point we will validate that we are=20 > fully in sync, tear down pg10 and send writes to pg15. Our question is= =20 > how we can validate our sync status. Given that there have been no DDL= =20 > changes on pg10 (new tables, for instance), would the following check be= =20 > sufficient? >=20 > Compare byte diff between WAL LSNs: > SELECT abs(pg_wal_lsn_diff(write_lsn, flush_lsn)) AS lag FROM=20 > pg_stat_replication; >=20 > If the byte diff is 0, I would assume that we're fully in sync. Is this= =20 > understanding correct? I would compare the last replayed log sequence number with the current position on the primary: SELECT abs(pg_wal_lsn_diff(pg_current_wal_lsn(), replay_lsn)) AS lag FROM pg_stat_replication; If that is 0, you are good. Yours, Laurenz Albe