Re: Brain dump: btree collapsing

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Curtis Faith" <curtis(at)galtcapital(dot)com>
Cc: "'Hannu Krosing'" <hannu(at)tm(dot)ee>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Brain dump: btree collapsing
Date: 2003-02-14 20:18:57
Message-ID: 9218.1045253937@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

"Curtis Faith" <curtis(at)galtcapital(dot)com> writes:
> 4) This could easily be reordered into:

> buf = ReadBuffer(rel, blkno); /* pin next page
> */
> LockBuffer(buf, BUFFER_LOCK_UNLOCK); /* release lock on
> current page */
> LockBuffer(buf, BT_READ); /* lock next page */
> ReleaseBuffer(buf); /* now release pin on
> previously current page */

> without affecting the logic of the code or causing any deadlock
> problems since the release still occurs before the lock of the next
> page.

Sorry, that *does* create deadlocks. Remember the deletion process is
going to need superexclusive lock (not only a BT_WRITE buffer lock,
but no concurrent pins) in order to be sure there are no scans stopped
on the page it wants to delete. (In the above pseudocode, the fact that
you still hold a pin on the previously-current page makes you look
exactly like someone who's in the middle of scanning that page, rather
than trying to leave it.) The same would be true of both pages
if it's trying to merge.

> 5) A mutex/spinlock that was stored in the index could be acquired by
> the scan code like this:

"Stored in the index"? And how will you do that portably? But it
doesn't matter, because the approach deadlocks.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2003-02-14 20:19:36 Re: location of the configuration files
Previous Message Peter Eisentraut 2003-02-14 20:14:30 Re: location of the configuration files