Skip site navigation (1) Skip section navigation (2)

Re: Think I see a btree vacuuming bug

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Think I see a btree vacuuming bug
Date: 2002-08-26 21:20:24
Message-ID: 200208262120.g7QLKO120865@candle.pha.pa.us (view raw or flat)
Thread:
Lists: pgsql-hackers
Tom Lane wrote:
> If a VACUUM running concurrently with someone else's indexscan were to
> delete the index tuple that the indexscan is currently stopped on, then
> we'd get a failure when the indexscan resumes and tries to re-find its
> place.  (This is the infamous "my bits moved right off the end of the
> world" error condition.)  What is supposed to prevent that from

Certainly anything that makes this error message less likely is bad. 
Perhaps we need to hook up a random() call to output the error message
to balance this.  :-)

> happening is that the indexscan retains a buffer pin (but not a read
> lock) on the index page containing the tuple it's stopped on.  VACUUM
> will not delete any tuple until it can get a "super exclusive" lock on
> the page (cf. LockBufferForCleanup), and the pin prevents it from doing
> so.
> 
> However: suppose that some other activity causes the index page to be
> split while the indexscan is stopped, and that the tuple it's stopped
> on gets relocated into the new righthand page of the pair.  Then the
> indexscan is holding a pin on the wrong page --- not the one its tuple
> is in.  It would then be possible for the VACUUM to arrive at the tuple
> and delete it before the indexscan is resumed.

OK, let me see if I can summarize:

	Index scan stops on dead index tuple, holds pin
	Someone inserts/updates and the page splits
	Vacuum comes along and removes the index tuple

And the problem is that after the split, the index scan doesn't hold a
pin on the newly split page.

This seems more like a problem that the index scan pin doesn't prevent
it from losing the pin after a split.  Could we just block splits of
pages containing pins?  If the page splits, how does the index scan
find the new page to start again?  Could the index scan be made to
handle cases where the index tuple it was stopped on is gone?

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman(at)candle(dot)pha(dot)pa(dot)us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073

In response to

Responses

pgsql-hackers by date

Next:From: Bruce MomjianDate: 2002-08-26 21:35:20
Subject: Re: Efficient DELETE Strategies
Previous:From: Alvaro HerreraDate: 2002-08-26 20:49:07
Subject: Re: [HACKERS] pg_attribute.attisinherited ?

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group