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 1iArrM-0003mB-W4 for pgsql-hackers@arkaria.postgresql.org; Thu, 19 Sep 2019 08:32:17 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iArrL-0003hp-Ju for pgsql-hackers@arkaria.postgresql.org; Thu, 19 Sep 2019 08:32:15 +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 1iArrJ-0003hT-TW for pgsql-hackers@lists.postgresql.org; Thu, 19 Sep 2019 08:32:15 +0000 Received: from out2-smtp.messagingengine.com ([66.111.4.26]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1iArrH-0003YC-0y for pgsql-hackers@lists.postgresql.org; Thu, 19 Sep 2019 08:32:12 +0000 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 093362261E; Thu, 19 Sep 2019 04:32:09 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Thu, 19 Sep 2019 04:32:09 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paquier.xyz; h= date:from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=fm2; bh=7WX+wgTbPY14GVWM6zFt7WKxGql coLAUnl8dngLJzjQ=; b=QyXk1T7tc2KVUj/rw0tvg0LhQ5WFWUGnQPcFCcIu/e/ ewG417jAxsmm/pRa1X45eD3OUKyvz2GFI2dMRB/fVvvX7fa+ljuXODWLyvktuXhn VeeEvWQK+5fAWLOZi0PEHoq0GY6/dZjLyBj5lGgSUsvxpX+Zid5qlrYKuhzBrJJX J6uFP6CPwTZK4G7vpDbb9pUDxc3jQO0/5PrtlkRcuQdfIJ1XDZuAnLmCB7hWayvs CiugSm2mJOc2azwppON+Giy4PpuHIjspWK+GL4zYGOCu2y+pnmHIAV3dAhswdkRl Epdhd7poGKmx5dmHH97jN+cI//RLEJVwfKW6WIiGNGw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; bh=7WX+wg TbPY14GVWM6zFt7WKxGqlcoLAUnl8dngLJzjQ=; b=0uFSr9/mcyLwfqvJmIH2Fm RR0ZL1ZHCFScC4swX8p7N8R34UYqVtEHlkrR0e3LzNhs2U4a7pknR7bHROYm7I5Z e93uvY/EclKiLkde/xUB6uTA84VGDyF65bYYoLinsLc84h3Xg4TeCmbmZj6om2Qq aZRQa7UDFg5EL9t01xBTtrQq0CVv6+C5qa4Cgr5XhqtviK0sBzyGVW+Bn3I+i2V4 b4/tUq0ZlpgUe2243UQ5YKt2ms13w0MaLqdW26AIRYN3oGlfsuQmxFErLqUkCVJ0 kqILCNgDHOMkgXFoZBlEOP/MnuUSTEDls00NPsvlT1sDmMLdykN5MiE7b2noZxcw == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedufedrvddtgddtiecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenfg hrlhcuvffnffculdejtddmnecujfgurhepfffhvffukfhfgggtuggjsehgtderredttddv necuhfhrohhmpefoihgthhgrvghlucfrrghquhhivghruceomhhitghhrggvlhesphgrqh huihgvrhdrgiihiieqnecukfhppeduuddurddutddvrddukedtrddukeehnecurfgrrhgr mhepmhgrihhlfhhrohhmpehmihgthhgrvghlsehprghquhhivghrrdighiiinecuvehluh hsthgvrhfuihiivgeptd X-ME-Proxy: Received: from paquier.xyz (ee0822lan1.rev.em-net.ne.jp [111.102.180.185]) by mail.messagingengine.com (Postfix) with ESMTPA id 25F0BD6005B; Thu, 19 Sep 2019 04:32:05 -0400 (EDT) Date: Thu, 19 Sep 2019 17:32:03 +0900 From: Michael Paquier To: Thomas Munro Cc: Nikolay Shaplov , Dent John , PostgreSQL Hackers , Alvaro Herrera , Tom Lane , Robert Haas Subject: Re: [PATCH] src/test/modules/dummy_index -- way to test reloptions from inside of access method Message-ID: <20190919083203.GC21144@paquier.xyz> References: <17071942.m9zZutALE6@x200m> <20190319070913.GE2899@paquier.xyz> <1562184.o3gKksHyEI@x200m> <6EED2D0C-6FC9-4958-BA6C-632E19210531@QQdd.eu> <1862640.9qQ6WrGjfI@x200m> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="kVXhAStRUZ/+rrGn" Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --kVXhAStRUZ/+rrGn Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Sep 19, 2019 at 10:51:09AM +1200, Thomas Munro wrote: > Let's see if I can see this on my Mac... yep, with "make -C > src/test/modules/dummy_index_am directory check" I see a similar > failure with "ERROR: unrecognized lock mode: 2139062143". I changed > that to a PANIC and got a core file containing this stack: A simple make check on the module reproduces the failure, so that's hard to miss. =46rom what I can see it is not a problem caused directly by this module, specifically knowing that this test module is actually copying what bloom is doing when declaring its reloptions. Take this example: CREATE EXTENSION bloom; CREATE TABLE tbloom AS SELECT (random() * 1000000)::int as i1, (random() * 1000000)::int as i2, (random() * 1000000)::int as i3, (random() * 1000000)::int as i4, (random() * 1000000)::int as i5, (random() * 1000000)::int as i6 FROM generate_series(1,100); CREATE INDEX bloomidx ON tbloom USING bloom (i1,i2,i3) WITH (length=3D80, col1=3D2, col2=3D2, col3=3D4); ALTER INDEX bloomidx SET (length=3D100); And then you get that: ERROR: XX000: unrecognized lock mode: 2139062143 LOCATION: LockAcquireExtended, lock.c:756 So the options are registered in the relOpts array managed by reloptions.c but the data is not properly initialized. Hence when looking at the lock needed we have an option match, but the lock number is incorrect, causing the failure. It looks like there is no direct way to enforce the lockmode used for a reloption added via add_int_reloption which does the allocation to add the option to add_reloption(), but enforcing the value to be initialized fixes the issue: --- a/src/backend/access/common/reloptions.c +++ b/src/backend/access/common/reloptions.c @@ -658,6 +658,7 @@ allocate_reloption(bits32 kinds, int type, const char *name, const char *desc) newoption->kinds =3D kinds; newoption->namelen =3D strlen(name); newoption->type =3D type; + newoption->lockmode =3D AccessExclusiveLock; MemoryContextSwitchTo(oldcxt); I would think that initializing that to a sane default is something that we should do anyway, or is there some trick allowing the manipulation of relOpts I am missing? Changing the relopts APIs in back-branches is a no-go of course, but we could improve that for 13~. While reading through the code, I found some extra issues... Here are some comments about them. +++ b/src/test/modules/dummy_index_am/Makefile @@ -0,0 +1,21 @@ +# contrib/bloom/Makefile Incorrect copy-paste here. +extern IndexBulkDeleteResult *dibulkdelete(IndexVacuumInfo *info, + IndexBulkDeleteResult *stats, IndexBulkDeleteCallback callback, + void *callback_state); All the routines defining the index AM can just be static, so there is no point to complicate dummy_index.h with most of its contents. Some routines are missing a (void) in their declaration when the routines have no arguments. This can cause warnings. No sure I see the point of the various GUC with the use of WARNING messages to check the sanity of the parameters. I find that awkward. -- Michael --kVXhAStRUZ/+rrGn Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAl2DPQMACgkQnvQgOdby QH0m+Q//T8PK6H3OkgrQJ4FN2rknzphOmkhfrs1GHKSEINtyKTBLHvji26VmKJql IbpDHDPnZCWXf9KCDd2cajS0SqAGjoggw5fSUf6Q6XZu3HmLpGoSyGDzkofhTg24 zkqmnf9YRYaRKUB/aQFKm4Q/9RYwWEnmPcr5qSZQQ2D0Ix93TyFGg7nf00dwi/Df DYSb1cU08BMfd36LUsg+Rzig2OXk47f7wVpRcvQiottI4mohqKeADrPPNyEKgVhO iy1u6CcZ5EvHWyiqjPE9DImcnJSHdh3fmdbzAuiTkmk8X6ax2YsUJ8I09EM6LEpR SkeNPFGXvOX/zLrHfFFoI4hCg2UK7kCPcdPQHW4rFjEGKQ3fJTSMNPDddcei4KfV /Ij4ekyh5KWWWMDEJT9R0kpLXLjxRZivBsBIDeyquUoZV2gEj1zhh6onWmTYvmy0 jdOTTrJX/WLVGETWtZEFIK2IqrESqHv3On1gWOkbRF/fmc2q7DVLA2qFjpAAUa2y Ew4z4r/8Zrh85BV8GoxqGFAwCAMLmuAm/Q5tz4jhntyd+4vPajBq/2CNvvr+413Y cjVF7ohZk++UgVVdgeaWz4q/K7Y4OKEgLV2fYq+rXaYpX/ZN5f0smWR2G5gPUtJP ToHJ1wc1OcwYOvD/V3Yv7L5K/HWHTzzwBJQxUz9d84eE9y63VFQ= =XrNZ -----END PGP SIGNATURE----- --kVXhAStRUZ/+rrGn--