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.96) (envelope-from ) id 1wmX3H-000prx-0R for pgsql-hackers@arkaria.postgresql.org; Wed, 22 Jul 2026 13:31:59 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wmX3F-00CPki-17 for pgsql-hackers@arkaria.postgresql.org; Wed, 22 Jul 2026 13:31:56 +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.96) (envelope-from ) id 1wmX3E-00CPjy-3C for pgsql-hackers@lists.postgresql.org; Wed, 22 Jul 2026 13:31:56 +0000 Received: from mail-qk1-x730.google.com ([2607:f8b0:4864:20::730]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wmX3B-00000001QPG-3wlZ for pgsql-hackers@postgresql.org; Wed, 22 Jul 2026 13:31:55 +0000 Received: by mail-qk1-x730.google.com with SMTP id af79cd13be357-930f618435cso81698185a.3 for ; Wed, 22 Jul 2026 06:31:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1784727114; x=1785331914; darn=postgresql.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=QftaI/AklhWDXphy1sMW+3rplKK8oJ8It2LOhrzqKM0=; b=T8eN3YDgzvLLl1bmCqJXq1S0Z70XsQM3a1mTfW+EX+qLqg0+LDh0lJaSn7pWVV79J9 BqV/s0T8OALIrP/soCbYQAQwzKsCSDF0Df7xzlsK4tUfYlAfp25eZh5owhvUYJJyFv8g J5he1lf7fHF1nuibkJYbXP7vLcL8eRxMbuAinynW9xiIH9DR/fxdlT4m8tjX/2HJge27 eIpEM5vr6RuywMBmx9QIfoM+nccmXp6h8pHs8c3JB6GbV229fQzHbXQVM0sAGFqZm5jg Buj9vu9A6K7ZgcPhi7jRIpE7DQjhSUHw4lszlAP+EwEL1oV8SDuU+Opu9cRE+1ZtmQCB eq2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784727114; x=1785331914; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=QftaI/AklhWDXphy1sMW+3rplKK8oJ8It2LOhrzqKM0=; b=EuA6/7cNrDBMXCXbTiKDAIZ8j0KqkN+vTMiWdKQHmTXtHMV6eQDxceX3GOIxL3O+6D sbo+505LomkSj/jJtW7b2uKruc2onTO+14zbuwB4ZoUkKq6JRylFwEDza7tNsc7wqNpI s60357kXNh5DL6ged2fcETSE42btSuYFF6BHO/p5NFlF/hx/8u9KiCWNnRrGtqvyP73D BMT5s9rqbndC/CETovJXF/+KtlOjJDAlzrNjGwrtGH2Ko9L3b4IgnGfjyosQwP0OB1kc UBBLdsvdkMksIIlVGEmlrorx+k/zLFPIxxyywrjQ9jDlqkBHz/1oaFJRi7N2UbBPthqo 5YvA== X-Forwarded-Encrypted: i=1; AHgh+RpFeyidUGmWJ0W7cjRp3ne78r1p5K+pODkgYzq0I/JWLnmzXroG94H7y3zx3uz/nql+jcWpqvRfV5PsKU3I@postgresql.org X-Gm-Message-State: AOJu0YxmQYo38clWJzkmHurWQjIiyoL0dqrHsGtdC9srMdWkXHWsPc7D 5L3OmhOH9hyBf+uvLoGiFXI5qlP+EJldTBo99n6qLZiO86gA+TbqKUGkwAvQrVaX X-Gm-Gg: AR+sD138/tYmwxar28tIAgkvqjNidwU1RydQZDsTt3z05ZrWRObhAJw4TiMa4zW5Qop QriJiL24IzA37lqr0B9vsjmpO2DCpD7mVzLJZ0b0ug6DYmm8bO9gFvG79LiXYE8u9x1TxHz3MKM IDEqEJ+CEWT3oK9y3mWdlVxf7YwVCPsUE/CEmWKg7AB1LKl5IMVvptYxsSGVjnImUya+luzPCe6 Al0+rPED83zJ0bdP86jbO632LcKbjPX79P+q9srnJv/3ZbJX6sxBN2UXoH2DM9lKN1BSZEJpmqF fxsTxChjcT2lfbHP+jU+IJlu5gCB0uJmyuV2w43kz4P1zRGvUcq32bece7kwBhsj9q6Y/84YpWW Pv9atWrHww/s/66ock3NMUpIqAD1yif5hUgVMOKFioLoFx9+agHwS4tjW2//JdI5Pcki2dESj07 8kO9b98oXK+RmvzPX6/3bVs+fbS894cORBPUS+d8RRtbFz X-Received: by 2002:a05:6214:4e16:b0:907:82de:4309 with SMTP id 6a1803df08f44-90782de434amr222728386d6.2.1784727113584; Wed, 22 Jul 2026 06:31:53 -0700 (PDT) Received: from nathan ([2600:382:b606:ca0:611e:1c00:d8ac:92cf]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-907ba9ddd4bsm21195786d6.26.2026.07.22.06.31.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Jul 2026 06:31:52 -0700 (PDT) Date: Wed, 22 Jul 2026 09:31:49 -0400 From: Nathan Bossart To: Andres Freund Cc: Peter Eisentraut , pgsql-hackers@postgresql.org Subject: Re: convert various variables to atomics Message-ID: References: <9d8c317d-d933-46c7-b675-4b9308eaca2b@eisentraut.org> 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 On Wed, Jul 22, 2026 at 09:19:39AM -0400, Andres Freund wrote: > On 2026-07-22 09:06:44 -0400, Nathan Bossart wrote: >> > /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ >> > - int startupBufferPinWaitBufId; >> > + pg_atomic_uint32 startupBufferPinWaitBufId; >> >> I may just be undercaffeinated, but what is wrong with this case? AFAICT >> the casting should work as expected, and I see other examples that do >> something similar, like avLauncherProc. > > The comment says -1, which doesn't really make sense for an unsigned variable. Ah. It looks like we could use 0 as the sentinel and simplify the call sites. They subtract one before calling SetStartupBufferPinWaitBufId() and add one after calling GetStartupBufferPinWaitBufId(). -- nathan