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 1rSAxa-00BtFT-9x for pgsql-bugs@arkaria.postgresql.org; Tue, 23 Jan 2024 07:12:38 +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 1rSAxY-00ANP3-SX for pgsql-bugs@arkaria.postgresql.org; Tue, 23 Jan 2024 07:12:36 +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.94.2) (envelope-from ) id 1rSAxY-00ANOv-JX for pgsql-bugs@lists.postgresql.org; Tue, 23 Jan 2024 07:12:36 +0000 Received: from meesny.iki.fi ([2001:67c:2b0:1c1::201]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rSAxV-002v88-E2 for pgsql-bugs@lists.postgresql.org; Tue, 23 Jan 2024 07:12:35 +0000 Received: from [192.168.1.115] (dsl-hkibng22-54f8db-125.dhcp.inet.fi [84.248.219.125]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: hlinnaka) by meesny.iki.fi (Postfix) with ESMTPSA id 4TJyvt03hZzyNX; Tue, 23 Jan 2024 09:12:25 +0200 (EET) Message-ID: Date: Tue, 23 Jan 2024 09:12:25 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: MarkBufferDirty Assert held LW_EXCLUSIVE lock fail when ginFinishSplit Content-Language: en-US To: Michael Paquier Cc: feichanghong , pgsql-bugs References: <053bc845-3cb5-445e-8ea4-00f6c678ee25@iki.fi> From: Heikki Linnakangas In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 23/01/2024 01:38, Michael Paquier wrote: > On Mon, Jan 22, 2024 at 10:47:17PM +0200, Heikki Linnakangas wrote: >> Michael, it was a pleasure to write this test with the injection points, >> compared to trying to set up PITR at just the right moment. Thank you! Since >> this is the first test that uses it, I didn't have any precedence to >> copy-paste; can you take a look and verify if this is how you imagined the >> facility to be used? > > I was wondering how many weeks it would take for somebody to begin > playing with that, and here you are 12 hours later.. :-D > +EXTRA_INSTALL = src/test/modules/injection_points > [...] > +#ifdef USE_INJECTION_POINTS > + if (GinPageIsLeaf(BufferGetPage(stack->buffer))) > + INJECTION_POINT("gin-leave-leaf-split-incomplete"); > + else > + INJECTION_POINT("gin-leave-internal-split-incomplete"); > +#endif > > Yes, that would be one way of doing it. It makes the code a bit more > invasive but that would work. Now, you expect this point to be > conditional depending on the state of the buffer. One thing I was > thinking of was to extend the APIs in injection_point.c to be able to > handle a set of arguments as a set of (void*) so as callbacks could > internally decide what they want to do depending on the running state. > I didn't have a use for it, but well, you do, so perhaps we could just > bite the bullet and do it. > > That reduces the footprint on the backend code, moving more logic > behind USE_INJECTION_POINTS in injection_point.c. At the end, you > should be able to patch the core backend with something like that, > without using some ifdefs on USE_INJECTION_POINTS: > INJECTION_POINT_1ARG("gin-leave-leaf-split", (void *) buffer) > > And INJECTION_POINT_1ARG() would be just a wrapper around something > like: > extern void InjectionPointRun1(const char *name, void *arg1); I can see that being useful in general. It requires a bespoken callback function, though. One nice thing about this test was that I didn't need to write a new C module, only that snippet at the injection point and some SQL. In more complicated tests a new C module is warranted, but I think a lot of tests - like this gin test - can be written without it. Perhaps if the argument was uint64 instead of a pointer, so that the 'injection_point' module could contain ready-made functions that do things with the argument. Overall I feel we should not bother with injection point arguments for now, though. Let's wait until we have a few more tests that would benefit from that, and then we'll have more information on what the ideal interface would look like. -- Heikki Linnakangas Neon (https://neon.tech)