Re: Move PinBuffer and UnpinBuffer to atomics - Mailing list pgsql-hackers

From Dilip Kumar
Subject Re: Move PinBuffer and UnpinBuffer to atomics
Date
Msg-id CAFiTN-skAMbHyXGYt+moeFSN4iOW5r+D30Hgetfn5C3262WP0g@mail.gmail.com
Whole thread Raw
In response to Re: Move PinBuffer and UnpinBuffer to atomics  (Dilip Kumar <dilipbalaut@gmail.com>)
Responses Re: Move PinBuffer and UnpinBuffer to atomics  (Alexander Korotkov <a.korotkov@postgrespro.ru>)
Document "59.2. Built-in Operator Classes" have a clerical error?  (osdba <mailtch@163.com>)
List pgsql-hackers

On Tue, Mar 22, 2016 at 12:31 PM, Dilip Kumar <dilipbalaut@gmail.com> wrote:
! pg_atomic_write_u32(&bufHdr->state, state);
  } while (!StartBufferIO(bufHdr, true));

Better Write some comment, about we clearing the BM_LOCKED from stage directly and need not to call UnlockBufHdr explicitly.
otherwise its confusing.

Few more comments..

*** 828,837 ****
    */
   do
   {
LockBufHdr(bufHdr);
Assert(bufHdr->flags & BM_VALID);
bufHdr->flags &= ~BM_VALID;
UnlockBufHdr(bufHdr);
   } while (!StartBufferIO(bufHdr, true));
   }
   }
--- 826,834 ----
    */
   do
   {
uint32 state = LockBufHdr(bufHdr);
state &= ~(BM_VALID | BM_LOCKED);
pg_atomic_write_u32(&bufHdr->state, state);
   } while (!StartBufferIO(bufHdr, true));

1. Previously there was a Assert, any reason why we removed it ?
 Assert(bufHdr->flags & BM_VALID);

2. And also if we don't need assert then can't we directly clear BM_VALID flag from state variable (if not locked) like pin/unpin buffer does, without taking buffer header lock?


--
Regards,
Dilip Kumar
EnterpriseDB: http://www.enterprisedb.com

pgsql-hackers by date:

Previous
From: Amit Kapila
Date:
Subject: Re: [HACKERS] Re: [HACKERS] Re: [HACKERS] Windows service is not starting so there’s message in log: FATAL: "could not create shared memory segment “Global/PostgreSQL.851401618”: Permission denied”
Next
From: Kyotaro HORIGUCHI
Date:
Subject: Re: Identifying a message in emit_log_hook.