Re: adding wait_start column to pg_locks

Поиск
Список
Период
Сортировка
От Fujii Masao
Тема Re: adding wait_start column to pg_locks
Дата
Msg-id ef0dd522-9096-a60f-a0fa-5f0a0fdbafbd@oss.nttdata.com
обсуждение исходный текст
Ответ на Re: adding wait_start column to pg_locks  (torikoshia <torikoshia@oss.nttdata.com>)
Ответы Re: adding wait_start column to pg_locks
Список pgsql-hackers

On 2021/02/02 22:00, torikoshia wrote:
> On 2021-01-25 23:44, Fujii Masao wrote:
>> Another comment is; Doesn't the change of MyProc->waitStart need the
>> lock table's partition lock? If yes, we can do that by moving
>> LWLockRelease(partitionLock) just after the change of
>> MyProc->waitStart, but which causes the time that lwlock is being held
>> to be long. So maybe we need another way to do that.
> 
> Thanks for your comments!
> 
> It would be ideal for the consistency of the view to record "waitstart" during holding the table partition lock.
> However, as you pointed out, it would give non-negligible performance impacts.
> 
> I may miss something, but as far as I can see, the influence of not holding the lock is that "waitstart" can be NULL
eventhough "granted" is false.
 
> 
> I think people want to know the start time of the lock when locks are held for a long time.
> In that case, "waitstart" should have already been recorded.

Sounds reasonable.


> If this is true, I think the current implementation may be enough on the condition that users understand it can
happenthat "waitStart" is NULL and "granted" is false.
 
> 
> Attached a patch describing this in the doc and comments.
> 
> 
> Any Thoughts?

64-bit fetches are not atomic on some platforms. So spinlock is necessary when updating "waitStart" without holding the
partitionlock? Also GetLockStatusData() needs spinlock when reading "waitStart"?
 


+       Lock acquisition wait start time.

Isn't it better to describe this more clearly? What about the following?

     Time when the server process started waiting for this lock,
     or null if the lock is held.

+       Note that updating this field and lock acquisition are not performed
+       synchronously for performance reasons.  Therefore, depending on the
+       timing, it can happen that <structfield>waitstart</structfield> is
+       <literal>NULL</literal> even though
+       <structfield>granted</structfield> is false.

I agree that it's helpful to add the note about that NULL can be returned even when "granted" is false. But IMO we
don'tneed to document why this behavior can happen internally. So what about the following?
 

     Note that this can be null for a very short period of time after
     the wait started even though <structfield>granted</structfield>
     is <literal>false</literal>.

Since the document for pg_locks uses "null" instead of <literal>NULL</literal> (I'm not sure why, though), I used
"null"for the sake of consistency.
 

Regards,

-- 
Fujii Masao
Advanced Computing Technology Center
Research and Development Headquarters
NTT DATA CORPORATION



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Recording foreign key relationships for the system catalogs
Следующее
От: Pavel Stehule
Дата:
Сообщение: bugfix - plpgsql - statement counter is incremented 2x for FOR stmt