Thread

Commits

  1. Use LW_SHARED in dsa.c where possible.

  1. use LW_SHARED in dsa_get_total_size()

    Nathan Bossart <nathandbossart@gmail.com> — 2025-12-02T17:17:39Z

    On Tue, Dec 02, 2025 at 10:31:33AM -0600, Nathan Bossart wrote:
    > On Tue, Dec 02, 2025 at 02:28:29PM +0530, Rahila Syed wrote:
    >> Thank you for highlighting the discussions. I'm unsure about the best
    >> approach here, but I think it would be safe to stay consistent with the
    >> rest of the code in dsa.c, especially since it's unclear that the use of
    >> LW_EXCLUSIVE for reading values in dsa is a mistake.
    > 
    > Okay.  I switched to LW_EXCLUSIVE and will consider starting a new thread
    > to use LW_SHARED when possible in dsa.c.
    
    Here is a patch that switches to LW_SHARED in dsa_get_total_size() and
    dsa_get_total_size_from_handle().  Another candidate was dsa_dump(), but
    that function appears to do some things that require more than a shared
    lock.  In any case, it's just a debugging function, and I found no uses
    in-tree or elsewhere.
    
    -- 
    nathan
    
  2. Re: use LW_SHARED in dsa_get_total_size()

    Sami Imseih <samimseih@gmail.com> — 2025-12-02T18:41:15Z

    > On Tue, Dec 02, 2025 at 10:31:33AM -0600, Nathan Bossart wrote:
    > > On Tue, Dec 02, 2025 at 02:28:29PM +0530, Rahila Syed wrote:
    > >> Thank you for highlighting the discussions. I'm unsure about the best
    > >> approach here, but I think it would be safe to stay consistent with the
    > >> rest of the code in dsa.c, especially since it's unclear that the use of
    > >> LW_EXCLUSIVE for reading values in dsa is a mistake.
    > >
    > > Okay.  I switched to LW_EXCLUSIVE and will consider starting a new thread
    > > to use LW_SHARED when possible in dsa.c.
    >
    > Here is a patch that switches to LW_SHARED in dsa_get_total_size() and
    > dsa_get_total_size_from_handle().
    
    I think this is a good idea. Exclusive here is not necessarily for the
    size lookups.
    A specific case I can think of is the work I have been investigating to move
    pg_stat_statements query text to shared memory, concurrent backends may
    need to check the size of the DSA concurrently, and this will prevent backends
    from being blocked when doing so.
    
    If it turns out a backend needs to modify the DSA, they will require
    an Exclusive
    lock, but that will be after the lookup.
    
    --
    Sami Imseih
    Amazon Web Services (AWS)
    
    
    
    
  3. Re: use LW_SHARED in dsa_get_total_size()

    Nathan Bossart <nathandbossart@gmail.com> — 2025-12-02T22:41:59Z

    On Tue, Dec 02, 2025 at 12:41:15PM -0600, Sami Imseih wrote:
    > I think this is a good idea. Exclusive here is not necessarily for the
    > size lookups.
    
    Committed, thanks for reviewing.
    
    -- 
    nathan