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 1mwlI0-0006v5-SX for pgsql-bugs@arkaria.postgresql.org; Mon, 13 Dec 2021 13:22:49 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mwlHz-0003hT-OC for pgsql-bugs@arkaria.postgresql.org; Mon, 13 Dec 2021 13:22:47 +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 1mwhuJ-0004QN-55 for pgsql-bugs@lists.postgresql.org; Mon, 13 Dec 2021 09:46:07 +0000 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1mwhuC-0005TU-OC for pgsql-bugs@lists.postgresql.org; Mon, 13 Dec 2021 09:46:06 +0000 Received: by mail-wm1-x335.google.com with SMTP id y196so11425596wmc.3 for ; Mon, 13 Dec 2021 01:46:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=altmetric.com; s=google; h=date:from:subject:to:cc:message-id:in-reply-to:references :mime-version; bh=PxdZ7TYT/9Ma43hA1QXoeN9ZwI6SQu1BRHtxg50hCe8=; b=NJomvi43p0G3qwei+ylZvtSOTQgXXTZeGSmDJdxd7TtsVXLVcNN6qrnspw/OmDfv9z vaAgf74A11wypbOwduMKvzasnt1/1aifGNb7FWtwdZ9k75YApfmIfK/B51o0L8XKN7+N 39708cFAUovlNC2+C6XY+xnsqhWGhVioI8q3U= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:subject:to:cc:message-id:in-reply-to :references:mime-version; bh=PxdZ7TYT/9Ma43hA1QXoeN9ZwI6SQu1BRHtxg50hCe8=; b=oiigPaASgpaSXCypNHb54FHhXXxI3V2J99oOyzrOvdJsMZpjm3da1MWA6wE7BxJtOo ccd0P5bLFCzWX+0NGlUcr1aEl3vy6aGJHDeCGtOuT7B9mA5nsY0VQiAsMGD8Az7qhqeO XQ7fj3KqQ2DyvrTRi9fne40lDAPwtT+uGui6RBaB2Zzjb5myTCw+SFM9AiOv5VQOGYF7 8WCPw2gk6dZbEdXu083KQDLuA+1BlL2yGZqmVS/sYCdJY8PVbECeUpwjrgnTqCOgALHm 869f/pPcAYrAI2199Lg79rgL4PDWBpn65TK9bAJ2JUoMa2ZeGFa/JDSRRykYksIc0iBx PL1g== X-Gm-Message-State: AOAM531k8CbHz5N9DczSfnn2DS4EV1lePEIEf1y5j4lPHj5BhVmX+Szy yJeRVbQrH05eCnUZPFfpehnD3Q== X-Google-Smtp-Source: ABdhPJxsJBs8ed3+kPAEne0ZJ76tfb2w6tUTEKRM7MOepyjI9Cx8ClzgEhiN3vUAAvs8Q328jE77Fg== X-Received: by 2002:a05:600c:19d0:: with SMTP id u16mr35893566wmq.111.1639388758127; Mon, 13 Dec 2021 01:45:58 -0800 (PST) Received: from [192.168.1.163] (10.16.93.209.dyn.plus.net. [209.93.16.10]) by smtp.gmail.com with ESMTPSA id h15sm7236220wrt.104.2021.12.13.01.45.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Dec 2021 01:45:57 -0800 (PST) Date: Mon, 13 Dec 2021 09:45:51 +0000 From: Alex Enachioaie Subject: Re: BUG #17327: Postgres server does not correctly emit error for max_slot_wal_keep_size being breached To: Kyotaro Horiguchi Cc: pgsql-bugs@lists.postgresql.org Message-Id: In-Reply-To: <20211213.144442.1533332056665514669.horikyota.ntt@gmail.com> References: <17327-89d0efa8b9ae6271@postgresql.org> <20211213.144442.1533332056665514669.horikyota.ntt@gmail.com> X-Mailer: geary/41.dev MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="=-orfQ6kmTasK4xoE5xA0n" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --=-orfQ6kmTasK4xoE5xA0n Content-Type: text/plain; charset=us-ascii; format=flowed Hello Kyotaro, Understood, that makes sense re: invalidation and what I assumed might be happening. I think I'm happy to leave the method of resolution up to you, I think the main point for me would be that when a replication process gets terminated as a consequence of the underlying temporary replication slot reaching max_slot_wal_keep_size that we log a specific message to indicate to the user the cause of the termination rather than leave it ambiguous. Thank you King regards Alex E Senior Site Reliability Engineer Altmetric On Mon, Dec 13 2021 at 14:44:42 +0900, Kyotaro Horiguchi wrote: > At Fri, 10 Dec 2021 15:46:11 +0000, Alex Enachioaie > > wrote in >> So, essentially the server side log emmitted on a temporary >> replication breaching max_slot_wal_keep_size limit is only: >> >> 2021-12-03 16:21:54 UTC [29724-2647] LOG: terminating process 42601 >> to >> release replication slot "pg_basebackup_42601" >> >> whereas for a persistent replication slot we get an additional line >> that clearly states _why_ the replication process was terminated: >> >> 2021-12-03 00:57:16 UTC [29724-2645] LOG: terminating process 3899 >> to >> release replication slot "backup" >> 2021-12-03 00:57:16 UTC [29724-2646] LOG: invalidating slot "backup" >> because its restart_lsn 47198/1E000000 exceeds >> max_slot_wal_keep_size >> >> I'm not sure if this means that in the case of a temporary slot it >> does not get invalidated at all (I've not looked at the code), or >> it's >> simply that we don't emit a log message when it does because the >> slot >> would be discarded anyway, but such a message would be very useful >> for >> diagnostic purposes imo. > > The "invalidating slot" message is emitted when the slot needs to be > invalidated, that is, when the slot persists after the user process is > terminated. Thus the message cannot be seen for temporary slots since > they are removed at process termination and no longer exist after > that. > > At Wed, 08 Dec 2021 11:23:35 +0000, PG Bug reporting form > > wrote in >> The core issue here then in our opinion is that Postgres server >> should log >> an error when the max_slot_wal_keep_size limit is reached for >> temporary >> replication slots as well as for permanent ones as otherwise >> users/administrators are presented only with non-descript connection >> termination errors which do not point to the actual cause of the >> problem. > > If you mean the "invalidating slot" message by "an error", that > wouldn't happen since invalidation is actually doesn't happen. Or, we > could change the message like this. Does this make sense for you? > >> LOG: terminating process 42601 to release temporary replication >> slot "pg_basebackup_42601" >> DETAIL: The slot will be dropped by the process termination. > > >> LOG: terminating process 3899 to release persistent replication >> slot "backup" > ... >> LOG: invalidating slot "backup" because its restart_lsn >> 47198/1E000000 exceeds max_slot_wal_keep_size > > regards. > > -- > Kyotaro Horiguchi > NTT Open Source Software Center --=-orfQ6kmTasK4xoE5xA0n Content-Type: text/html; charset=us-ascii Content-Transfer-Encoding: quoted-printable
Hello Kyotaro,

Understood, that makes sense re: invalidation and what I assumed migh= t be happening.

I think I'm happy to leave the met= hod of resolution up to you, I think the main point for me would be that wh= en a 
replication process gets terminated as a consequence o= f the underlying temporary replication slot reaching max_slot_wal_keep_size=
that we log a specific message to indicate to the user the cause= of the termination rather than leave it ambiguous.

Thank you

King regards

= Alex E
Senior Site Reliability Engineer
Altmetric
=

On Mon, Dec 13 2021 at 14:44= :42 +0900, Kyotaro Horiguchi <horikyota.ntt@gmail.com> wrote:
At Fri, 10 Dec 2021 15:46:11 +0000, Alex Enachioaie <alex@altmetric.com> wrote in=20
So, essentially the server side log emmitted on a temporary replication breaching max_slot_wal_keep_size limit is only: =20 2021-12-03 16:21:54 UTC [29724-2647] LOG: terminating process 42601 to release replication slot "pg_basebackup_42601" =20 whereas for a persistent replication slot we get an additional line that clearly states _why_ the replication process was terminated: =20 2021-12-03 00:57:16 UTC [29724-2645] LOG: terminating process 3899 to release replication slot "backup" 2021-12-03 00:57:16 UTC [29724-2646] LOG: invalidating slot "backup" because its restart_lsn 47198/1E000000 exceeds max_slot_wal_keep_size =20 I'm not sure if this means that in the case of a temporary slot it does not get invalidated at all (I've not looked at the code), or it's simply that we don't emit a log message when it does because the slot would be discarded anyway, but such a message would be very useful for diagnostic purposes imo.
The "invalidating slot" message is emitted when the slot needs to be invalidated, that is, when the slot persists after the user process is terminated. Thus the message cannot be seen for temporary slots since they are removed at process termination and no longer exist after that. At Wed, 08 Dec 2021 11:23:35 +0000, PG Bug reporting form <noreply@postgresql.org> wrote in=20
The core issue here then in our opinion is that Postgres serve= r should log an error when the max_slot_wal_keep_size limit is reached for temporary replication slots as well as for permanent ones as otherwise users/administrators are presented only with non-descript connection termination errors which do not point to the actual cause of the problem.
If you mean the "invalidating slot" message by "an error", that wouldn't happen since invalidation is actually doesn't happen. Or, we could change the message like this. Does this make sense for you?
LOG: terminating process 42601 to release temporary replicati= on slot "pg_basebackup_42601" DETAIL: The slot will be dropped by the process termination.
LOG: terminating process 3899 to release persistent replicati= on slot "backup"=20
...
LOG: invalidating slot "backup" because its restart_lsn 47198= /1E000000 exceeds max_slot_wal_keep_size
regards.
--=20
Kyotaro Horiguchi NTT Open Source Software Center
--=-orfQ6kmTasK4xoE5xA0n--