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 1rfw8T-003Dxv-CI for pgsql-hackers@arkaria.postgresql.org; Fri, 01 Mar 2024 06:12:45 +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 1rfw7T-00BnsC-OT for pgsql-hackers@arkaria.postgresql.org; Fri, 01 Mar 2024 06:11:44 +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 1rfw7T-00Bnrn-BE for pgsql-hackers@lists.postgresql.org; Fri, 01 Mar 2024 06:11:43 +0000 Received: from mail-lf1-x134.google.com ([2a00:1450:4864:20::134]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1rfw7L-002HRW-Fu for pgsql-hackers@postgresql.org; Fri, 01 Mar 2024 06:11:42 +0000 Received: by mail-lf1-x134.google.com with SMTP id 2adb3069b0e04-5132444ac00so497207e87.1 for ; Thu, 29 Feb 2024 22:11:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709273495; x=1709878295; darn=postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=xpX+IYBf+nDz/waKJay2K/+Xb7ohg6GWoiGqykm3QVc=; b=bCP3laW7UJIJcu2JS05IjmTlvw3jwqMtrBYD6o0n33Gww7FjSBnQ2IcNUCkLTTO4+0 okAQQVlpDmQ4QKu1KQ7Vqq4F1qdhhApZFMQer45WE1udWgYA9DA0p3Z6+5CMJg28f3hb OIqE/r2k0kyff8Hiv+3YbuiAOea16FrCfjLXBwjR5YA32/WKxRUwn6kYo75+324lgRXj Jr9ijqnE7wkPxhIBM2h9u/5qpLrNnhfhSacG5byniOrb78iQQk5DO0EPKkBkrNdkI5eJ Feot3+cHQfuxf4yUNNy9sicjUI/qYYyb8xtNmV4xdEvZM+1l+t4N1n3Mhmu83WTQvoS4 GE2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709273495; x=1709878295; h=content-transfer-encoding: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=xpX+IYBf+nDz/waKJay2K/+Xb7ohg6GWoiGqykm3QVc=; b=moOVxUYpaVnjZ/1OX9+hGkRFw+3KBQ+wL4fRYStAB9cT7kwQDsPhyNgs07yZ/ip2hi q5cIWvsAm0ASCpG22Eggv4yl0qBGCLkINTf3b+SK/ZADFsKbZThIOurcS8VYWncZWHG1 4MH0w3Qe59l63lZBhMcD7uid3wxU1bT1kQmLx5+nqgqHrQgXxpFwiKghR7H9A9AejwjD EZXHB69rYSBe4dmHd9zIrErt9Frj06n6rsAoPPLCbGOtaBW/C8CMVEdm56qVUiWq4JHl RjfEBuHVob08UbtVpcrtO/lr1L+u2b2ruO0/YyXlg7YGIx7H1tWrhsIGFAWewMoI4wCR 4WzA== X-Forwarded-Encrypted: i=1; AJvYcCWPL7EKVBwfgteyE493cMtlcNPQCiu+dCwQAKirUQ6G1MDAN+s6O92Xq8XVgBsvyShZ61A33MEIomg4Hgv4xmVzDXK2YkKx81BgeiQo X-Gm-Message-State: AOJu0Yw7ufkpPy6rd3hUB1l+VS9WjBympTTd569lW91/BVk+261hQdrr BiohivKmTfuaP75movDpmFbWexJhCrcAK5K9IvwCXCSb5lbvhTrMtNGogo4+inLKxkn/zFTajv3 zKr0iRpXe3w6pvXkdZowhzs5k0j8= X-Google-Smtp-Source: AGHT+IF5BTXr5c8/oP6Df4ySBMQ5EclKzGtYDDJp60C5y0lG7gxS53zCa5g/YvdUuLutZpXPas/SlIn6cosluMG1Yik= X-Received: by 2002:ac2:52b0:0:b0:512:ac4c:c91 with SMTP id r16-20020ac252b0000000b00512ac4c0c91mr364758lfm.1.1709273494732; Thu, 29 Feb 2024 22:11:34 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Masahiko Sawada Date: Fri, 1 Mar 2024 15:10:57 +0900 Message-ID: Subject: Re: Synchronizing slots from primary to standby To: "Zhijie Hou (Fujitsu)" Cc: Amit Kapila , shveta malik , Ajin Cherian , Dilip Kumar , Nisha Moond , "Hayato Kuroda (Fujitsu)" , Peter Smith , Bertrand Drouvot , Bharath Rupireddy , Peter Eisentraut , Bruce Momjian , Ashutosh Sharma , Andres Freund , pgsql-hackers , Alvaro Herrera Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Fri, Mar 1, 2024 at 12:42=E2=80=AFPM Zhijie Hou (Fujitsu) wrote: > > On Friday, March 1, 2024 10:17 AM Zhijie Hou (Fujitsu) wrote: > > > > > > Attach the V102 patch set which addressed Amit and Shveta's comments. > > Thanks Shveta for helping addressing the comments off-list. > > The cfbot reported a compile warning, here is the new version patch which= fixed it, > Also removed some outdate comments in this version. > Thank you for updating the patch! I've reviewed the v102-0001 patch. Here are some comments: --- I got a compiler warning: walsender.c:1829:6: warning: variable 'wait_event' is used uninitialized whenever '&&' condition is false [-Wsometimes-uninitialized] if (!XLogRecPtrIsInvalid(RecentFlushPtr) && ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ walsender.c:1871:7: note: uninitialized use occurs here if (wait_event =3D=3D WAIT_EVENT_WAL_SENDER_WAIT_FOR_WAL) ^~~~~~~~~~ walsender.c:1829:6: note: remove the '&&' if its condition is always true if (!XLogRecPtrIsInvalid(RecentFlushPtr) && ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ walsender.c:1818:20: note: initialize the variable 'wait_event' to silence this warning uint32 wait_event; ^ =3D 0 1 warning generated. --- +void +assign_standby_slot_names(const char *newval, void *extra) +{ + List *standby_slots; + MemoryContext oldcxt; + char *standby_slot_names_cpy =3D extra; + Given that the newval and extra have the same data (standby_slot_names value), why do we not use newval instead? I think that if we use newval, we don't need to guc_strdup() in check_standby_slot_names(), we might need to do list_copy_deep() instead, though. It's not clear to me as there is no comment. --- + + standby_slot_oldest_flush_lsn =3D min_restart_lsn; + IIUC we expect that standby_slot_oldest_flush_lsn never moves backward. If so, I think it's better to have an assertion here. --- Resetting standby_slot_names doesn't work: =3D# alter system set standby_slot_names to ''; ERROR: invalid value for parameter "standby_slot_names": """" DETAIL: replication slot "" does not exist --- + /* + * Switch to the memory context under which GUC variables are allo= cated + * (GUCMemoryContext). + */ + oldcxt =3D MemoryContextSwitchTo(GetMemoryChunkContext(standby_slot_names_cpy)); + standby_slot_names_list =3D list_copy(standby_slots); + MemoryContextSwitchTo(oldcxt); Why do we not explicitly switch to GUCMemoryContext? --- + if (!standby_slot_names_list) + return true; + Probably "standby_slot_names_list =3D=3D NIL" is more consistent with other places. The same can be applied in WaitForStandbyConfirmation(). --- + /* + * Return true if all the standbys have already caught up to the passed in + * WAL localtion. + */ + s/localtion/location/ --- I was a bit surprised by the fact that standby_slot_names value is handled in a different way than a similar parameter synchronous_standby_names. For example, the following command doesn't work unless there is a replication slot 'slot1, slot2': =3D# alter system set standby_slot_names to 'slot1, slot2'; ERROR: invalid value for parameter "standby_slot_names": ""slot1, slot2"" DETAIL: replication slot "slot1, slot2" does not exist Whereas "alter system set synchronous_standby_names to stb1, stb2;" can correctly separate the string into 'stb1' and 'stb2'. Probably it would be okay since this behavior of standby_slot_names is the same as other GUC parameters that accept a comma-separated string. But I was confused a bit the first time I used it. --- + /* + * "*" is not accepted as in that case primary will not be able to= know + * for which all standbys to wait for. Even if we have physical sl= ots + * info, there is no way to confirm whether there is any standby + * configured for the known physical slots. + */ + if (strcmp(*newval, "*") =3D=3D 0) + { + GUC_check_errdetail("\"*\" is not accepted for standby_slot_names"); + return false; + } Why only '*' is checked aside from validate_standby_slots()? I think that the doc doesn't mention anything about '*' and '*' cannot be used as a replication slot name. So even if we don't have this check, it might be no problem. Regards, --=20 Masahiko Sawada Amazon Web Services: https://aws.amazon.com