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 1sHwtk-00Bjcm-Kd for pgsql-hackers@arkaria.postgresql.org; Fri, 14 Jun 2024 02:42:40 +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 1sHwth-00BsD7-Rv for pgsql-hackers@arkaria.postgresql.org; Fri, 14 Jun 2024 02:42:38 +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 1sHwth-00BsBD-86 for pgsql-hackers@lists.postgresql.org; Fri, 14 Jun 2024 02:42:38 +0000 Received: from mail-yb1-xb29.google.com ([2607:f8b0:4864:20::b29]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1sHwta-001ZAH-U4 for pgsql-hackers@postgresql.org; Fri, 14 Jun 2024 02:42:37 +0000 Received: by mail-yb1-xb29.google.com with SMTP id 3f1490d57ef6-dfb05bcc50dso1700608276.0 for ; Thu, 13 Jun 2024 19:42:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=leadboat.com; s=google; t=1718332949; x=1718937749; darn=postgresql.org; h=user-agent: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=pn2bTKWPaFHVqQ5Qq+K5Try2b2Rc4pzaYUfN4VuqmRM=; b=d7CKGzKsOSXERwdLP3mkMxzw1mDUkl67W6zd6/kImgIfhiiqelw4R/UnicTK2EFaG5 NWMv5bQkNe/KPsJ3rAjR2wUPoGidcBsE75wsupIj9GgH6Gi8XJlBe7rxcLl2jBabwvU2 wJMY+T9hq9CC/EPIvtgQY9A/8thJyHuC49sU8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718332949; x=1718937749; h=user-agent: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=pn2bTKWPaFHVqQ5Qq+K5Try2b2Rc4pzaYUfN4VuqmRM=; b=TnlyvlwzDYzdQFrODK3NQp0fBCuwMFemJAeoMAdNqFMVijC92OLE/6rnaMlwpz2Bth NRSNisve8GMMDxqHZSWzlNrQBn2jV7AaFlKL03hBAUQKsrSND9/dR6dwplPgTWyClla0 sLGJPu/ou/qwV/TbHpcq/QpwHXlpGeqTEoiOEroYVuQclsmu1XSdhylLj5C/JqVpuDga lWVvGlEuQFpexaw1eNcMlpgyIGt2hxh+DAZToGLqqTV0+R/WiH+PYg/a7j4DFyr/UHxf YWT+naml9cDJWK2P2xlgG58TeIerd3buEnVTiyAJVRXBW09dKjeElN230cIfsrx69cac 3hvg== X-Forwarded-Encrypted: i=1; AJvYcCWTPfAohdWoxwydTuBo8J+G+xOL2DQz6PejQW1rFCx65NfsQnb2OW1xO0Ppl4Cj459wdSWu9jB8jLm95TnBcdg5ZcWY0TYN0t7Ph5nE X-Gm-Message-State: AOJu0Yx5F0wcR2fkhYy7e61YtvlQI1f2verdTQsB1lpH+lFbVBT+2bAf yXAB+2PP8cFwSEpxRCAKFkoaFdhCutT2q5VZfjxP8542+9mJ+wJx4nNMA1XtbQ== X-Google-Smtp-Source: AGHT+IG5Ki371fVyvqNASaqF8m1oPNaqtQlQ1+5Ilvwx5L4Gkdby+QkgIFnt25pUPKOxaSxJQRfFxw== X-Received: by 2002:a25:dc87:0:b0:dfa:ac81:38e8 with SMTP id 3f1490d57ef6-dff1534dca5mr1357680276.6.1718332948854; Thu, 13 Jun 2024 19:42:28 -0700 (PDT) Received: from rfd.leadboat.com ([2600:1702:a20:5750::48]) by smtp.gmail.com with ESMTPSA id 3f1490d57ef6-dff04a4d8a0sm382434276.40.2024.06.13.19.42.27 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jun 2024 19:42:28 -0700 (PDT) Date: Thu, 13 Jun 2024 19:42:25 -0700 From: Noah Misch To: Michael Paquier Cc: Robert Haas , pgsql-hackers@postgresql.org, Tom Lane , Smolkin Grigory Subject: Re: race condition in pg_class Message-ID: <20240614024225.d6@rfd.leadboat.com> References: <20231027214946.79.nmisch@google.com> <1617596.1698446455@sss.pgh.pa.us> <20231027232612.99.nmisch@google.com> <20231102030915.d3.nmisch@google.com> <20240512232923.aa.nmisch@google.com> <20240605181706.fe.nmisch@google.com> <20240611024525.9f.nmisch@google.com> <20240614003549.c2.nmisch@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/2.2.12 (2023-09-09) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Fri, Jun 14, 2024 at 09:58:59AM +0900, Michael Paquier wrote: > Looking at inplace031-inj-wait-event.. > > The comment at the top of GetWaitEventCustomNames() requires an > update, still mentioning extensions. Thanks. Fixed locally. > GetWaitEventCustomIdentifier() is incorrect, and should return > "InjectionPoint" in the default case of this class name, no? I intentionally didn't provide a default event ID for InjectionPoint. PG_WAIT_EXTENSION needs a default case for backward compatibility, if nothing else. For this second custom type, it's needless complexity. The value 0x0B000000U won't just show up like PG_WAIT_EXTENSION does. GetLWLockIdentifier() also has no default case. How do you see it? > I would > just pass the classID to GetWaitEventCustomIdentifier(). As you say, that would allow eventId==0 to raise "could not find custom wait event" for PG_WAIT_INJECTIONPOINT instead of wrongly returning "Extension". Even if 0x0B000000U somehow does show up, having pg_stat_activity report "Extension" instead of an error, in a developer test run, feels unimportant to me. > It is suboptimal to have pg_get_wait_events() do two scans of > WaitEventCustomHashByName. Wouldn't it be better to do a single scan, > returning a set of (class_name,event_name) fed to the tuplestore of > this SRF? Micro-optimization of pg_get_wait_events() doesn't matter. I did consider that or pushing more of the responsibility into wait_events.c, but I considered it on code repetition grounds, not performance grounds. > uint32 > WaitEventExtensionNew(const char *wait_event_name) > { > + return WaitEventCustomNew(PG_WAIT_EXTENSION, wait_event_name); > +} > + > +uint32 > +WaitEventInjectionPointNew(const char *wait_event_name) > +{ > + return WaitEventCustomNew(PG_WAIT_INJECTIONPOINT, wait_event_name); > +} > > Hmm. The advantage of two routines is that it is possible to control > the class IDs allowed to use the custom wait events. Shouldn't the > second routine be documented in xfunc.sgml? The patch added to xfunc.sgml an example of using it. I'd be more inclined to delete the WaitEventExtensionNew() docbook documentation than to add its level of detail for WaitEventInjectionPointNew(). We don't have that kind of documentation for most extension-facing C functions.