Thread

Commits

  1. Replace CAS loop with single TAS in ProcArrayGroupClearXid()

  1. pg_atomic_exchange_u32() in ProcArrayGroupClearXid()

    Alexander Korotkov <a.korotkov@postgrespro.ru> — 2018-09-21T17:35:28Z

    Hi!
    
    While investigating ProcArrayGroupClearXid() code I wonder why do we have
    this loop instead of plain pg_atomic_exchange_u32() call?  Is it
    intentional?
    
    /*
    * Now that we've got the lock, clear the list of processes waiting for
    * group XID clearing, saving a pointer to the head of the list.  Trying
    * to pop elements one at a time could lead to an ABA problem.
    */
    while (true)
    {
    nextidx = pg_atomic_read_u32(&procglobal->procArrayGroupFirst);
    if (pg_atomic_compare_exchange_u32(&procglobal->procArrayGroupFirst,
       &nextidx,
       INVALID_PGPROCNO))
    break;
    }
    
    ------
    Alexander Korotkov
    Postgres Professional: http://www.postgrespro.com
    The Russian Postgres Company
    
  2. Re: pg_atomic_exchange_u32() in ProcArrayGroupClearXid()

    Amit Kapila <amit.kapila16@gmail.com> — 2018-09-22T06:55:09Z

    On Fri, Sep 21, 2018 at 11:06 PM Alexander Korotkov
    <a.korotkov@postgrespro.ru> wrote:
    >
    > Hi!
    >
    > While investigating ProcArrayGroupClearXid() code I wonder why do we have this loop instead of plain pg_atomic_exchange_u32() call?
    >
    
    We can use pg_atomic_exchange_u32 instead of a loop.  In fact, clog
    code uses pg_atomic_exchange_u32 for the same purpose.  I think it is
    better to make the code consistent at both places.  Feel free to
    change it, otherwise, I can take care of it in a few days time.
    
    -- 
    With Regards,
    Amit Kapila.
    EnterpriseDB: http://www.enterprisedb.com
    
    
    
  3. Re: pg_atomic_exchange_u32() in ProcArrayGroupClearXid()

    Alexander Korotkov <a.korotkov@postgrespro.ru> — 2018-09-22T13:28:21Z

    On Sat, Sep 22, 2018 at 9:55 AM Amit Kapila <amit.kapila16@gmail.com> wrote:
    
    > On Fri, Sep 21, 2018 at 11:06 PM Alexander Korotkov
    > <a.korotkov@postgrespro.ru> wrote:
    > > While investigating ProcArrayGroupClearXid() code I wonder why do we
    > have this loop instead of plain pg_atomic_exchange_u32() call?
    >
    > We can use pg_atomic_exchange_u32 instead of a loop.  In fact, clog
    > code uses pg_atomic_exchange_u32 for the same purpose.  I think it is
    > better to make the code consistent at both places.  Feel free to
    > change it, otherwise, I can take care of it in a few days time.
    >
    
    Thank you for feedback.  Pushed.
    
    ------
    Alexander Korotkov
    Postgres Professional: http://www.postgrespro.com
    The Russian Postgres Company