From: | Fujii Masao <masao(dot)fujii(at)oss(dot)nttdata(dot)com> |
---|---|
To: | torikoshia <torikoshia(at)oss(dot)nttdata(dot)com> |
Cc: | Ian Lawrence Barwick <barwick(at)gmail(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, Justin Pryzby <pryzby(at)telsasoft(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: adding wait_start column to pg_locks |
Date: | 2021-02-03 02:23:37 |
Message-ID: | 3db333a9-31f7-a225-8038-eeb835ba8f37@oss.nttdata.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On 2021/02/03 1:49, Fujii Masao wrote:
>
>
> 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 even though "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 happen that "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 partition lock? Also GetLockStatusData() needs spinlock when reading "waitStart"?
Also it might be worth thinking to use 64-bit atomic operations like pg_atomic_read_u64(), for that.
Regards,
--
Fujii Masao
Advanced Computing Technology Center
Research and Development Headquarters
NTT DATA CORPORATION
From | Date | Subject | |
---|---|---|---|
Next Message | Amit Kapila | 2021-02-03 02:34:23 | Re: Single transaction in the tablesync worker? |
Previous Message | Kyotaro Horiguchi | 2021-02-03 02:18:05 | Re: libpq debug log |