Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sZSf9-001AHb-S4 for pgsql-general@arkaria.postgresql.org; Thu, 01 Aug 2024 10:03:59 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1sZSf8-006nz8-Er for pgsql-general@arkaria.postgresql.org; Thu, 01 Aug 2024 10:03:58 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sZSf8-006nwU-3V for pgsql-general@lists.postgresql.org; Thu, 01 Aug 2024 10:03:58 +0000 Received: from mail-lf1-x130.google.com ([2a00:1450:4864:20::130]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1sZSf5-002Wih-Ch for pgsql-general@lists.postgresql.org; Thu, 01 Aug 2024 10:03:56 +0000 Received: by mail-lf1-x130.google.com with SMTP id 2adb3069b0e04-52fc4388a64so11327531e87.1 for ; Thu, 01 Aug 2024 03:03:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1722506634; x=1723111434; darn=lists.postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=zXg/E11Xlh0GB94m72m1bYpDxyIGmz9jfxIuu1KrL/k=; b=Y4oGzo7O/FbwLfpSSBNVf6qrz+ilqTWif7j5shpaQbNryq5R1HFUvViSr16n1x++TV pBYYV6m+EEhuk5y+8Ms/ryvytSXkqRB0VuNjulaNryXq6RP8etFSSzXFvnGakhRaLg7m wqvG55tXo9nlceeaq4T5rkHGoYpBrIF/5NpG0y/pGk2zI/CEq4Epy6wPQ90xx2Y1Nyht O+IZsaSaDEgY0sU8A0C0hzStr4ctLzgoO3yFv9Anoftbkra3bN0UejpVqOyP7u6pv3uI 7GappBp8rxq8wF972mIi7rrJLMUShi/pdp/zaaMS1QJ4X6tGZ9Gr+Vl6qiFAc93VKrUe VilA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722506634; x=1723111434; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=zXg/E11Xlh0GB94m72m1bYpDxyIGmz9jfxIuu1KrL/k=; b=mw8ZsMY9oh6PG3X5sCcF0fJozRJzfjK7t+nYMFNywrvb0MvQqWqBGzmL5HLv6k+zFe zeQaLnn7Z3o7TbAQ3pq423snlb+/0SqcciU/2i6gHN0/AeM0HL5/HtZihFG7GtdZm9Bq 9JJL8Zxs5rZSyEGkSWTqF2uCmW/076MNuj8zJjy6CkWPw8cirnigg81LLq13yN2VBR0b 56vMDf9STzva747wGa3FBVRcPApKs3g0lV/FcYmI2BJo2r2hch0bcsp8LiCYfi25JA++ dy7/icS7Bic0CubldU6+rnvMznuzmK22uvXEE5YAw2MlQe70sK5FGZZkpR4G1/6Ag4ii eWAg== X-Gm-Message-State: AOJu0YwjcZUihEBlmnXnQxKuyYUyD1WTo44e9lSfKpLFXRcumAOd/5py lNoZ9yWFiCKhoqIJ4wIcC0dSPAIaiKYXmMgazUE1PWtru/L5x5qeSmKv5uq+AQgAPpdql9COzoD 7Gx3cd2AOQoIci5pBYQNV7u2xIHC7C8ozmw== X-Google-Smtp-Source: AGHT+IFY2SgWQ35pd/RFIaTacL4sAkSqcrGtiIbYavmPctxEHjTlFGjXaO+paTv7bCREfAGutL1mfrTUw5eno6/IEUw= X-Received: by 2002:a05:6512:46e:b0:52e:fd53:a251 with SMTP id 2adb3069b0e04-530b61ff375mr1001302e87.59.1722506633338; Thu, 01 Aug 2024 03:03:53 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: =?UTF-8?Q?Torsten_F=C3=B6rtsch?= Date: Thu, 1 Aug 2024 12:03:41 +0200 Message-ID: Subject: Re: Logical replication slots on slaves/replicas? To: Piotr Andreassen Blasiak Cc: pgsql-general@lists.postgresql.org Content-Type: multipart/alternative; boundary="00000000000000e8ae061e9c54df" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --00000000000000e8ae061e9c54df Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable A COMMIT record in the WAL has an LSN. I don't know much about debezuim but wal2json can give you this LSN. Then there is this function, pg_last_wal_replay_lsn(). I think you could run it on the replica to see if you are after the point of commit. If you are, you should be able to see the changes made by the transaction. BTW, I am sure I can construct a situation where you see your transaction in the logical wal stream before it becomes visible on the master. In particular, this is possible with a sync replication setup. So, I would not trust to always be able to see the transaction on the master as soon as it is reported committed in the wal stream. All the best, Torsten On Thu, Aug 1, 2024 at 10:42=E2=80=AFAM Piotr Andreassen Blasiak < piotr@attendium.com> wrote: > Hi, > > I know that currently logical replication slots are available only for > primary servers. Is there any plan to add this feature to read slaves as > well? My problem is this: > > I want to use debezium to stream changes from postgresql. But, if I strea= m > changes from the master I can not query my read slaves for related data t= o > these changes - I need to always query the master which is not scalable. = So > either I need a way to be able to know when the change has been propagate= d > to my read replica so that I can reliably query it, or I am hoping I can > simply read all the changes from the read replica which will mean it is > already up to date when I query it. > > Piotr Andreassen Blasiak > > > > > --00000000000000e8ae061e9c54df Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
A COMMIT record in the WAL has an LSN. I don't know mu= ch about debezuim=C2=A0but wal2json can give you this LSN. Then there is th= is function,=C2=A0pg_last_wal_replay_lsn(). I think you could run it on the= replica to see if you are after the point of commit. If you are, you shoul= d be able to see the changes made by the transaction.

BT= W, I am sure I can construct a situation where you see your transaction in = the logical wal stream before it becomes visible on the master. In particul= ar, this is possible with a sync replication setup. So, I would not trust t= o always be able to see the transaction on the master as soon as it is repo= rted committed in the wal stream.

All the best,
Torsten

--00000000000000e8ae061e9c54df--