Chao Li <[email protected]> writes:
> As $SUBJECT says, my understanding is no.
It's not a great idea, but I'm not sure it's fatal. There are places
that hold LWLocks for awhile.
> I think LWLocks are generally only held for a very short duration,
> like a few CPU cycles to read or modify some shared data,
Spinlocks are treated that way, but we're willing to hold LWLocks
longer. The main thing I'd be concerned about is that there is no
deadlock-detection infrastructure for LWLocks, so you'd better be
darn certain there is no possibility of deadlock. That usually
means you want to limit the extent of code that could run while
you're holding the lock.
In your specific example, the thing I'd be afraid of is that an
errcontext callback might do something you're not expecting.
We don't forbid errcontext callbacks from doing catalog lookups,
for instance. So on the whole I agree with this patch, with
or without any concrete example that fails.
regards, tom lane