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 1rcSTg-000FCZ-1v for pgsql-hackers@arkaria.postgresql.org; Tue, 20 Feb 2024 15:56:16 +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 1rcSSg-000aij-KK for pgsql-hackers@arkaria.postgresql.org; Tue, 20 Feb 2024 15:55:15 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rcSSg-000aib-B4 for pgsql-hackers@lists.postgresql.org; Tue, 20 Feb 2024 15:55:14 +0000 Received: from mail-wr1-x430.google.com ([2a00:1450:4864:20::430]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1rcSSd-0001q0-Bw for pgsql-hackers@lists.postgresql.org; Tue, 20 Feb 2024 15:55:14 +0000 Received: by mail-wr1-x430.google.com with SMTP id ffacd0b85a97d-33d6f1f17e5so422810f8f.3 for ; Tue, 20 Feb 2024 07:55:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708444510; x=1709049310; darn=lists.postgresql.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=c8r18X1PxK65EcSWB8RzCtTmMoOspRSJ4AIQHAKak9M=; b=MWgX+Qd08YVmUSgK9Z0N3S7iaGDFqP6wVVR7UoO3pjNRvpiaXj82Gg3CU7ldVRL7N6 lgySGPcNo2PVZ1d+cTHS5X4+rtuHhEDhVg1mtwc7fgDkMrQUXI9fCh5LDVMNHXlX/rk1 mOTpD314Js7EZirI8/2z83pUSPL2rO7IrKv5w1MEcDwlqblF3QRf62v3UEo6WsD0fy41 Y2bRQmwBp8MeKCDh5Ezd32CopydOhzOUr7UUYnVr+pe0aXGzavv9njxGuxaGY5gFzeNl S9jSF9C9ZBPnzi+vxTv9visozCjAbyqHNV2RlVVoGul2Fk3MmkSCOmZIMGbWZd+D5fDY sL1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708444510; x=1709049310; h=in-reply-to: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=c8r18X1PxK65EcSWB8RzCtTmMoOspRSJ4AIQHAKak9M=; b=noL6aQDTd7Y9sYZ7g03uW7I75qUsj2FKVUCYihJhX5uyIGzeq6NUnTNEWkPbTQndBx Q34nqqNK1BVeXn5hNeTxvP7SYjiJk63Z7SyHw27ZniNkQkx/qv7elT6bB7qbW6zbzVWq 0EIVKOeaixV0DtCKdylm/HG7X0RbYMQ0BCKo6T2JPOv2MmJ5OX3G2Fe+0yCNolQuTY/h F9A5tVCB2AT9POhbbFapmLv1J9WIxAIXtPWxZBq0HUJXTF9URT35/ZRMU4jYpvaAoJpj W2vAhNkWCxw4p0o1Mf2lJKVJExONJ6ec30ti8himD6KUaCzc1L7NpP8eqV0S1EQa8inq jHqw== X-Gm-Message-State: AOJu0Yz2G7IQ86kTE9woQWT05KCX6ZbJjOOKmCupyxeggY53e3buN9Ip ic5v3vshPUTVDZmr3VEhcDMXE+kxQm1Rdd8RNI9Vo0/5ETaUuMs1 X-Google-Smtp-Source: AGHT+IGQhFfuJKg+Six8P6HoXXkA+2LTVC4FODA9Rv8pTGr9mVN4Vluu5F/+Vdr1+CRDfY0JQeOCjg== X-Received: by 2002:adf:f492:0:b0:33d:3f21:b9f3 with SMTP id l18-20020adff492000000b0033d3f21b9f3mr4447465wro.64.1708444509944; Tue, 20 Feb 2024 07:55:09 -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 bq5-20020a5d5a05000000b0033d60ab6bc8sm4969076wrb.50.2024.02.20.07.55.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Feb 2024 07:55:09 -0800 (PST) Date: Tue, 20 Feb 2024 15:55:08 +0000 From: Bertrand Drouvot To: Michael Paquier Cc: Postgres hackers , Ashutosh Bapat Subject: Re: Injection points: some tools to wait and wake Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, On Tue, Feb 20, 2024 at 08:28:28AM +0900, Michael Paquier wrote: > On Mon, Feb 19, 2024 at 02:28:04PM +0000, Bertrand Drouvot wrote: > > If slock_t protects "only" one counter, then what about using pg_atomic_uint64 > > or pg_atomic_uint32 instead? And btw do we need wait_counts at all? (see comment > > number 4) > > We could, indeed, even if we use more than one counter. Still, I > would be tempted to keep it in case more data is added to this > structure as that would make for less stuff to do while being normally > non-critical. This sentence may sound pedantic, though.. Okay, makes sense to keep this as it is as a "template" in case more stuff is added. + /* Counter advancing when injection_points_wake() is called */ + int wait_counts; In that case what about using an unsigned instead? (Nit) > > I'm wondering if this loop and wait_counts are needed, why not doing something > > like (and completely get rid of wait_counts)? > > > > " > > ConditionVariablePrepareToSleep(&inj_state->wait_point); > > ConditionVariableSleep(&inj_state->wait_point, injection_wait_event); > > ConditionVariableCancelSleep(); > > " > > > > It's true that the comment above ConditionVariableSleep() mentions that: > > Perhaps not, but it encourages good practices around the use of > condition variables, and we need to track all that in shared memory > anyway. Ashutosh has argued in favor of the approach taken by the > patch in the original thread when I've sent a version doing exactly > what you are saying now to not track a state in shmem. Oh okay I missed this previous discussion, let's keep it as it is then. New comments: 1 === +void +injection_wait(const char *name) Looks like name is not used in the function. I guess the reason it is a parameter is because that's the way the callback function is being called in InjectionPointRun()? 2 === +PG_FUNCTION_INFO_V1(injection_points_wake); +Datum +injection_points_wake(PG_FUNCTION_ARGS) +{ I think that This function will wake up all the "wait" injection points. Would that make sense to implement some filtering based on the name? That could be useful for tests that would need multiple wait injection points and that want to wake them up "sequentially". We could think about it if there is such a need in the future though. 3 === +# Register a injection point on the standby so as the follow-up typo: "an injection"? 4 === +for (my $i = 0; $i < 3000; $i++) +{ is 3000 due to?: +checkpoint_timeout = 30s If so, would that make sense to reduce the value for both? Regards, -- Bertrand Drouvot PostgreSQL Contributors Team RDS Open Source Databases Amazon Web Services: https://aws.amazon.com