Re: Is it OK to perform logging while holding a LWLock?
| От | Chao Li |
|---|---|
| Тема | Re: Is it OK to perform logging while holding a LWLock? |
| Дата | |
| Msg-id | 195D67C3-D767-43AA-89CB-262A8298B480@gmail.com обсуждение исходный текст |
| Ответ на | Re: Is it OK to perform logging while holding a LWLock? (Tom Lane <tgl@sss.pgh.pa.us>) |
| Список | pgsql-hackers |
> On Feb 11, 2026, at 11:19, Tom Lane <tgl@sss.pgh.pa.us> wrote: > > Chao Li <li.evan.chao@gmail.com> 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 Thanks for the detailed explanation. I’ve written this down in my notebook, very helpful. Best regards, -- Chao Li (Evan) HighGo Software Co., Ltd. https://www.highgo.com/
В списке pgsql-hackers по дате отправления: