pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
BUG #13487: GetBufferFromRing code bug
2+ messages / 2 participants
[nested] [flat]

* BUG #13487: GetBufferFromRing code bug
@ 2015-07-04 15:12  jingwei_5107@qq.com
  0 siblings, 1 reply; 2+ messages in thread

From: jingwei_5107@qq.com @ 2015-07-04 15:12 UTC (permalink / raw)
  To: pgsql-bugs

The following bug has been logged on the website:

Bug reference:      13487
Logged by:          will 
Email address:      jingwei_5107@qq.com
PostgreSQL version: 9.4.4
Operating system:   It does not matter
Description:        

In GetBufferFromRing method(/src/backend/storage/buffer/freelist.c),I think
the following code:
506     buf = &BufferDescriptors[bufnum - 1];
507	LockBufHdr(buf);
508	if (buf->refcount == 0 && buf->usage_count <= 1)
509	{
510		strategy->current_was_in_ring = true;
511		return buf;
512	}
513	UnlockBufHdr(buf);

should be changed to(Adding line 510):

506     buf = &BufferDescriptors[bufnum - 1];
507	LockBufHdr(buf);
508	if (buf->refcount == 0 && buf->usage_count <= 1)
509	{
510             UnlockBufHdr(buf);// add this line
511		strategy->current_was_in_ring = true;
512		return buf;
513	}
514	UnlockBufHdr(buf);

It should Unlock the buf before returning buf, after exclusively accessing
the buf's refcount&usage_count member.

Am I right? Any reply is appreciated if I'm wrong.



-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: BUG #13487: GetBufferFromRing code bug
@ 2015-07-06 02:43  Thomas Munro <thomas.munro@enterprisedb.com>
  parent: jingwei_5107@qq.com
  0 siblings, 0 replies; 2+ messages in thread

From: Thomas Munro @ 2015-07-06 02:43 UTC (permalink / raw)
  To: jingwei_5107@qq.com; +Cc: pgsql-bugs

On Sun, Jul 5, 2015 at 3:12 AM,  <jingwei_5107@qq.com> wrote:
> The following bug has been logged on the website:
>
> Bug reference:      13487
> Logged by:          will
> Email address:      jingwei_5107@qq.com
> PostgreSQL version: 9.4.4
> Operating system:   It does not matter
> Description:
>
> In GetBufferFromRing method(/src/backend/storage/buffer/freelist.c),I think
> the following code:
> 506     buf = &BufferDescriptors[bufnum - 1];
> 507     LockBufHdr(buf);
> 508     if (buf->refcount == 0 && buf->usage_count <= 1)
> 509     {
> 510             strategy->current_was_in_ring = true;
> 511             return buf;
> 512     }
> 513     UnlockBufHdr(buf);
>
> should be changed to(Adding line 510):
>
> 506     buf = &BufferDescriptors[bufnum - 1];
> 507     LockBufHdr(buf);
> 508     if (buf->refcount == 0 && buf->usage_count <= 1)
> 509     {
> 510             UnlockBufHdr(buf);// add this line
> 511             strategy->current_was_in_ring = true;
> 512             return buf;
> 513     }
> 514     UnlockBufHdr(buf);
>
> It should Unlock the buf before returning buf, after exclusively accessing
> the buf's refcount&usage_count member.
>
> Am I right? Any reply is appreciated if I'm wrong.



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2015-07-06 02:43 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2015-07-04 15:12 BUG #13487: GetBufferFromRing code bug jingwei_5107@qq.com
2015-07-06 02:43 ` Thomas Munro <thomas.munro@enterprisedb.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox