Re: Vaccuum allows read access?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Jan Wieck <JanWieck(at)Yahoo(dot)com>
Cc: PostgreSQL HACKERS <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Vaccuum allows read access?
Date: 2000-07-22 16:09:27
Message-ID: 5367.964282167@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

JanWieck(at)t-online(dot)de (Jan Wieck) writes:
> On the phone we discussed about the btree splitpage problems
> and you said that the current btree implementation is
> optimized for concurrent read and insert access, not so for
> concurrent deletes.

> This might get to be a problem with the overwriting storage
> manager. If it wants to reuse space of outdated tuples in
> the main heap, it needs to delete index tuples as well. Isn't
> that in conflict with the btree design?

Yes, it's going to be an issue. nbtscan.c only handles deletions
issued by the current backend, and thus is basically useful only
for VACUUM. We could change bt_restscan so that it tries scanning
left as well as right for the current item (it need only look as far
left as the start of the current page). But that doesn't help if
someone's deleted the index item that was your current item.

A simple solution is to hold onto a read lock for the current page
of a scan throughout the scan, rather than releasing and regrabbing
it as we do now. That might reduce the available concurrency quite
a bit, however. The worst case would be something like a CURSOR
that's been left sitting open --- it could keep the page locked for
a long time.

Another way is to change indexscans so that they fetch the referenced
main tuple directly, rather than simply handing back a TID for it,
and apply the HeapTupleSatisfies test immediately. Then we could
avoid having a scan stop on a tuple that might be a candidate to be
deleted. Would save some call overhead and lock/unlock overhead too.

A bigger problem is that this is all just for btrees. What about
rtrees and hash indexes? (Not to mention GIST, although I suspect
that's dead code...)

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2000-07-23 00:09:23 Re: lost records --- problem identified!
Previous Message The Hermit Hacker 2000-07-22 12:50:45 Re: Hello PL/Python