Re: pg_stat_statements: Avoid holding excessive lock - Mailing list pgsql-hackers

From wenhui qiu
Subject Re: pg_stat_statements: Avoid holding excessive lock
Date
Msg-id CAGjGUAJp1Ms06E0d6Z40K8OJ2cGiU1jjwa4MPe8LaZQ3z2cuFw@mail.gmail.com
Whole thread Raw
List pgsql-hackers
Hi Karina Liskevich 
> +             /*
> +              * There is no need to hold entry->mutex when reading stats_since and
> +              * minmax_stats_since for (unlike counters) they are always written
> +              * while holding pgss->lock exclusively. We are holding pgss->lock
> +              * shared so there should be no race here.
> +              */
>               stats_since = entry->stats_since;
>               minmax_stats_since = entry->minmax_stats_since;
> -             SpinLockRelease(&entry->mutex);

>> The comment could be simpler, say a "The spinlock is not required when
>> reading these two as they are always updated when holding pgss->lock
>> exclusively.".  Or something like that.
Agree , It reduces the lock time , The new comment are short and concise, It  sounds good .

Michael Paquier <michael@paquier.xyz> 于2024年11月8日周五 14:08写道:
On Thu, Nov 07, 2024 at 04:08:30PM +0300, Karina Litskevich wrote:
> Thank you for your feedback and the shorter wording of the comment.
> I used it in the new version of the patch.

After a second look, sounds good to me.  Let's wait a bit and see of
others have comments or thoughts to share.
--
Michael

pgsql-hackers by date:

Previous
From: jian he
Date:
Subject: Re: not null constraints, again
Next
From: Amit Kapila
Date:
Subject: Re: Commit Timestamp and LSN Inversion issue