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 1rQjzW-003Gw7-Jm for pgsql-hackers@arkaria.postgresql.org; Fri, 19 Jan 2024 08:12:43 +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 1rQjzV-007wUT-MP for pgsql-hackers@arkaria.postgresql.org; Fri, 19 Jan 2024 08:12:41 +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 1rQjzV-007wUL-Cy for pgsql-hackers@lists.postgresql.org; Fri, 19 Jan 2024 08:12:41 +0000 Received: from mail-yb1-xb36.google.com ([2607:f8b0:4864:20::b36]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1rQjzS-002Hnx-IL for pgsql-hackers@postgresql.org; Fri, 19 Jan 2024 08:12:40 +0000 Received: by mail-yb1-xb36.google.com with SMTP id 3f1490d57ef6-db3a09e96daso499759276.3 for ; Fri, 19 Jan 2024 00:12:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1705651957; x=1706256757; darn=postgresql.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=zgWUWKK3KBxUlgXHI6/xp35ZWOKjnUxtVMLSaKiEg2o=; b=RzfMDLaJQW2SqwDKSLq0Ki6lnfpQW3eskBGqFt3EH1bm/uV6zEebXe4q7OunqZxfwF N8R34pJGPVGJBiVTcWYHl4UtBc0ON5TtlZSMcnGe3WfeJexkKLqhOspSOeml1KWDGaIH o53yhFBJPyNUmgV0lpl9j6rhYN0g67IDo1IMx9dKTeJ/U6yUcMyy9QN351T/jr9X2+sk XCpBDgBJmwUJuEyyviXvuhBffMWRlI8VVu6tOf3LxHwOot5pZYW9bxd4c9iURVOMxjd0 3VeE0FgzKqQbLTiZo2V2jvXLk1momLeqzQBsguyqj3h6Vg3DFJdOVYPwLjq+pqkjTpig XLjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705651957; x=1706256757; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=zgWUWKK3KBxUlgXHI6/xp35ZWOKjnUxtVMLSaKiEg2o=; b=PlVgNSeV9SVqA5gLgaAC2tC79GGwJGIIytAmoURNuTt+8oax5CcI/1be/0vDBJoEuI DKkl9BI5e+6/iiQE48yqppTl2PVUABDvDZnuzi/fgMJxVs2PvOYkX4byWdQtFnpo2R1p 62Gs+smuaQ22FpvnsQkSu6jBBuDCQ2Czs8Ipq6GFXpnu0rdgjLorQM57YFo5k2Bcjvpz Vv3stkrn8vHCYUtXIH/UOkDCgA7zbB2M7m/uHvfAMcHQRnk7bXZpP3VzWQlGpakSeBC6 fbguUgDbfgOlZ62yFJHoLZDW1DAcoopxcfGzrhNSQbzhi67dKoc+agKH37uu0FbDovhV ZWUA== X-Gm-Message-State: AOJu0YzoyxuTVR5K72Md0CbJjteUJN0xZoEabo3EFuoI8W9cCdwwVKfV bKlcQ5L+hmIVrPdZTmtLXFlx/z4chXkg/pLa7uclp4RXcWwgyIE/ X-Google-Smtp-Source: AGHT+IEl9ZEVntM/XYujXrRp0qGArzpBiOPQhpKGXu+lKsAA03f5OdF5nYTJcTbQrYDL+dNX3lcdGA== X-Received: by 2002:a25:9207:0:b0:dbe:a0e2:c637 with SMTP id b7-20020a259207000000b00dbea0e2c637mr1786479ybo.65.1705651957458; Fri, 19 Jan 2024 00:12:37 -0800 (PST) Received: from ip-10-97-1-34.eu-west-3.compute.internal (ec2-15-236-134-5.eu-west-3.compute.amazonaws.com. [15.236.134.5]) by smtp.gmail.com with ESMTPSA id oj7-20020a056214440700b0068199a6c813sm786787qvb.4.2024.01.19.00.12.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Jan 2024 00:12:37 -0800 (PST) Date: Fri, 19 Jan 2024 08:12:33 +0000 From: Bertrand Drouvot To: shveta malik Cc: Amit Kapila , Masahiko Sawada , "Zhijie Hou (Fujitsu)" , Dilip Kumar , Peter Smith , Nisha Moond , "Hayato Kuroda (Fujitsu)" , Bharath Rupireddy , Peter Eisentraut , Bruce Momjian , Ashutosh Sharma , Andres Freund , pgsql-hackers , Ajin Cherian , Alvaro Herrera Subject: Re: Synchronizing slots from primary to standby Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, On Fri, Jan 19, 2024 at 11:46:51AM +0530, shveta malik wrote: > On Fri, Jan 19, 2024 at 11:23 AM Amit Kapila wrote: > > > > > > 5 === (coming from v62-0002) > > > > + Assert(tuplestore_tuple_count(res->tuplestore) == 1); > > > > > > > > Is it even possible for the related query to not return only one row? (I think the > > > > "count" ensures it). > > > > > > I think you are right. This assertion was added sometime back on the > > > basis of feedback on hackers. Let me review that again. I can consider > > > this comment in the next version. > > > > > > > OTOH, can't we keep the assert as it is but remove "= 1" from > > "count(*) = 1" in the query. There shouldn't be more than one slot > > with same name on the primary. Or, am I missing something? > > There will be 1 record max and 0 record if the primary_slot_name is > invalid. I think we'd have exactly one record in all the cases (due to the count): postgres=# SELECT pg_is_in_recovery(), count(*) FROM pg_replication_slots WHERE 1 = 2; pg_is_in_recovery | count -------------------+------- f | 0 (1 row) postgres=# SELECT pg_is_in_recovery(), count(*) FROM pg_replication_slots WHERE 1 = 1; pg_is_in_recovery | count -------------------+------- f | 1 (1 row) > Keeping 'count(*)=1' gives the benefit that it will straight > away give us true/false indicating if we are good or not wrt > primary_slot_name. I feel Assert can be removed and we can simply > have: > > if (!tuplestore_gettupleslot(res->tuplestore, true, false, tupslot)) > elog(ERROR, "failed to fetch primary_slot_name tuple"); > I'd also vote for keeping it as it is and remove the Assert. Regards, -- Bertrand Drouvot PostgreSQL Contributors Team RDS Open Source Databases Amazon Web Services: https://aws.amazon.com