public inbox for [email protected]  
help / color / mirror / Atom feed
From: Heikki Linnakangas <[email protected]>
To: pgsql-hackers <[email protected]>
Subject: Injection point locking
Date: Mon, 24 Jun 2024 13:29:38 +0300
Message-ID: <[email protected]> (raw)

InjectionPointRun() acquires InjectionPointLock, looks up the hash 
entry, and releases the lock:

> 	LWLockAcquire(InjectionPointLock, LW_SHARED);
> 	entry_by_name = (InjectionPointEntry *)
> 		hash_search(InjectionPointHash, name,
> 					HASH_FIND, &found);
> 	LWLockRelease(InjectionPointLock);

Later, it reads fields from the entry it looked up:

> 		/* not found in local cache, so load and register */
> 		snprintf(path, MAXPGPATH, "%s/%s%s", pkglib_path,
> 				 entry_by_name->library, DLSUFFIX);

Isn't that a straightforward race condition, if the injection point is 
detached in between?


Another thing:

I wanted use injection points to inject an error early at backend 
startup, to write a test case for the scenarios that Jacob point out at 
https://www.postgresql.org/message-id/CAOYmi%2Bnwvu21mJ4DYKUa98HdfM_KZJi7B1MhyXtnsyOO-PB6Ww%40mail.g.... 
But I can't do that, because InjectionPointRun() requires a PGPROC 
entry, because it uses an LWLock. That also makes it impossible to use 
injection points in the postmaster. Any chance we could allow injection 
points to be triggered without a PGPROC entry? Could we use a simple 
spinlock instead? With a fast path for the case that no injection points 
are attached or something?

-- 
Heikki Linnakangas
Neon (https://neon.tech)






view thread (2+ messages)

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected]
  Subject: Re: Injection point locking
  In-Reply-To: <[email protected]>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox