Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hkAWw-00056C-3S for pgsql-hackers@arkaria.postgresql.org; Sun, 07 Jul 2019 17:00:50 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hkAWu-0000Sw-0T for pgsql-hackers@arkaria.postgresql.org; Sun, 07 Jul 2019 17:00:48 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hkAWt-0000Sp-D9 for pgsql-hackers@lists.postgresql.org; Sun, 07 Jul 2019 17:00:47 +0000 Received: from mail-pf1-x441.google.com ([2607:f8b0:4864:20::441]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hkAWm-000639-AZ for pgsql-hackers@postgresql.org; Sun, 07 Jul 2019 17:00:45 +0000 Received: by mail-pf1-x441.google.com with SMTP id i189so6405688pfg.10 for ; Sun, 07 Jul 2019 10:00:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=leadboat.com; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=XTsXYXjLKdynk1dWDD4ngdP7uFKiCbKnbB5CnZOADXE=; b=YZOtGz7vN0b1KIDaqPQ67sk7WEsxZuOpxHCxaLbh/kaQFpF96UYHTvtdB234aY2qdA Drx7zTkXsVVyZPNJbg6uN8pCovjaa7rZcr3MtfZVn7Pr3/Z+uDJxKRkpV/sFt2XW3Z+a eTqtqGlwM2c2E2Aa5I+0cIQTdEaFyAXxLjvas= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=XTsXYXjLKdynk1dWDD4ngdP7uFKiCbKnbB5CnZOADXE=; b=nOQNWLnsel9ZiUZPPtAZm+9DjfrTY5o3X5LvswTq4yLCT9lJgSqJOsIjWoymD6D5Tj HhBJLZa8zLT1Ag/Ffs9IGEeabSWghN0iQK6hI/PqvZ0Qv+X2rZTItFzB4Q90Nt1NceqB SWYFPHdlof22jsfMw11ZYIXhsxjPSSAZKxD3CeMIsgmsHZV93LLOxOcWJw3t8p+AqCDs Qs5NoH1GjOC1nix0n4XloI9D4xj3SLpDs/kIj+OLLAyoID3BzYE7KyvmOMPvc9m27m1I eoCwvBQslCpRVIGeVZexJ57H8BEu6dKrzI+FdS8jzO79HZX85GCId4alp8eMdyMgAuD3 VSzw== X-Gm-Message-State: APjAAAUxSF5luUk0upReoiHN6KDxGBeG5CXdXatr6R4rWcVEYnAbX2Fc HXLYvec1rnRsp3PA1lOYHlrJrXYXaQY= X-Google-Smtp-Source: APXvYqyJIq7otBVbRK9KJgjzt5ON2AwlDhAWHWm9GiaCXWd765ugchGAA6fEGkzWZsbTmCEWTG559w== X-Received: by 2002:a65:4844:: with SMTP id i4mr18378473pgs.113.1562518838854; Sun, 07 Jul 2019 10:00:38 -0700 (PDT) Received: from rfd.leadboat.com (108-233-125-46.lightspeed.sntcca.sbcglobal.net. [108.233.125.46]) by smtp.gmail.com with ESMTPSA id a15sm12535244pgw.3.2019.07.07.10.00.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 07 Jul 2019 10:00:37 -0700 (PDT) Date: Sun, 7 Jul 2019 10:00:35 -0700 From: Noah Misch To: Andres Freund Cc: pgsql-hackers@postgresql.org Subject: Re: [RFC] Removing "magic" oids Message-ID: <20190707170035.GA1485546@rfd.leadboat.com> References: <20180930034810.ywp2c7awz7opzcfr@alap3.anarazel.de> <20181114080152.xkk6coduvfrh4ntr@alap3.anarazel.de> <20181115045728.GA1121738@rfd.leadboat.com> <20181115050241.exereob7wk3xxewj@alap3.anarazel.de> <20181120092004.f3j2znfodallkksn@alap3.anarazel.de> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="IS0zKkzwUGydFO0o" Content-Disposition: inline In-Reply-To: <20181120092004.f3j2znfodallkksn@alap3.anarazel.de> User-Agent: Mutt/1.5.24 (2015-08-30) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --IS0zKkzwUGydFO0o Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Tue, Nov 20, 2018 at 01:20:04AM -0800, Andres Freund wrote: > On 2018-11-14 21:02:41 -0800, Andres Freund wrote: > > On 2018-11-15 04:57:28 +0000, Noah Misch wrote: > > > On Wed, Nov 14, 2018 at 12:01:52AM -0800, Andres Freund wrote: > > > > - one pgbench test tested concurrent insertions into a table with > > > > oids, as some sort of stress test for lwlocks and spinlocks. I *think* > > > > this doesn't really have to be a system oid column, and this was just > > > > because that's how we triggered a bug on some machine. Noah, do I get > > > > this right? > > > > > > The point of the test is to exercise OidGenLock by issuing many parallel > > > GetNewOidWithIndex() and verifying absence of duplicates. There's nothing > > > special about OidGenLock, but it is important to use an operation that takes a > > > particular LWLock many times, quickly. If the test query spends too much time > > > on things other than taking locks, it will catch locking races too rarely. > > > > Sequences ought to do that, too. And if it's borked, we'd hopefully see > > unique violations. But it's definitely not a 1:1 replacement. > I've tested this on ppc. Neither the old version nor the new version > stress test spinlocks sufficiently to error out with weakened spinlocks > (not that surprising, there are no spinlocks in any hot path of either > workload). Both versions very reliably trigger on weakened lwlocks. So I > think we're comparatively good on that front. I tested this on xlc, the compiler that motivated the OID test, and the v12+ version of the test didn't catch the bug[1] with xlc 13.1.3. CREATE TYPE ... AS ENUM generates an OID for each label, so the attached patch makes the v12+ test have locking behavior similar to its v11 ancestor. [1] https://postgr.es/m/flat/a72cfcb0-37d0-de2f-b3ec-f38ad8d6a8cc@postgrespro.ru --IS0zKkzwUGydFO0o Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="lwlock-test-v1.patch" diff --git a/src/bin/pgbench/t/001_pgbench_with_server.pl b/src/bin/pgbench/t/001_pgbench_with_server.pl index dc2c72f..3b097a9 100644 --- a/src/bin/pgbench/t/001_pgbench_with_server.pl +++ b/src/bin/pgbench/t/001_pgbench_with_server.pl @@ -58,27 +58,20 @@ sub pgbench return; } -# Test concurrent insertion into table with serial column. This -# indirectly exercises LWLock and spinlock concurrency. This test -# makes a 5-MiB table. - -$node->safe_psql('postgres', - 'CREATE UNLOGGED TABLE insert_tbl (id serial primary key); '); - +# Test concurrent OID generation via pg_enum_oid_index. This indirectly +# exercises LWLock and spinlock concurrency. +my $labels = join ',', map { "'l$_'" } 1 .. 1000; pgbench( '--no-vacuum --client=5 --protocol=prepared --transactions=25', 0, [qr{processed: 125/125}], [qr{^$}], - 'concurrent insert workload', + 'concurrent OID generation', { '001_pgbench_concurrent_insert' => - 'INSERT INTO insert_tbl SELECT FROM generate_series(1,1000);' + "CREATE TYPE pg_temp.e AS ENUM ($labels); DROP TYPE pg_temp.e;" }); -# cleanup -$node->safe_psql('postgres', 'DROP TABLE insert_tbl;'); - # Trigger various connection errors pgbench( 'no-such-database', --IS0zKkzwUGydFO0o--