Unix Technical Forum

Re: database vacuum from cron hanging

This is a discussion on Re: database vacuum from cron hanging within the pgsql Hackers forums, part of the PostgreSQL category; --> "Kevin Grittner" <Kevin.Grittner@wicourts.gov> writes: > bufmgr.s file coming in separate (off-list) email. Yup, here is the smoking gun! This ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > pgsql Hackers

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-11-2008, 07:12 AM
Tom Lane
 
Posts: n/a
Default Re: database vacuum from cron hanging

"Kevin Grittner" <Kevin.Grittner@wicourts.gov> writes:
> bufmgr.s file coming in separate (off-list) email.


Yup, here is the smoking gun! This code in PinBuffer

LockBufHdr_NoHoldoff(buf);
buf->refcount++;
result = (buf->flags & BM_VALID) != 0;
UnlockBufHdr_NoHoldoff(buf);

is translated as

movb $1, %al
cmpb $0,28(%ebx)
jne 1f
lock
xchgb %al,28(%ebx) <-- acquire spinlock
1:
testb %al, %al
jne .L228 <-- (failure case is out-of-line)
..L221:
movl 20(%ebx), %ecx <-- fetch refcount
movw 16(%ebx), %ax
incl %ecx <-- increment refcount
movb $0, 28(%ebx) <-- release spinlock
shrl %eax
movl %ecx, 20(%ebx) <-- store back refcount
andl $1, %eax
movl %eax, %edi

For comparison, gcc 4.0.1 on my Fedora machine produces

movb $1, %al
cmpb $0,28(%ebx)
jne 1f
lock
xchgb %al,28(%ebx) <-- acquire spinlock
1:
testb %al, %al
jne .L117
incl 20(%ebx) <-- increment refcount
movw 16(%ebx), %ax
movb $0, 28(%ebx) <-- release spinlock
movl %eax, %edi
shrl %edi
andl $1, %edi
movl PrivateRefCount, %eax

which is safe.

What we probably need to do is insert some "volatile" qualifiers
to force the compiler to behave better. What happens to the code
if you change PinBuffer to be declared as

static bool
PinBuffer(volatile BufferDesc *buf)

?

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 3: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faq

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 03:17 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com