Unix Technical Forum

Dealing with dangling index pointers

This is a discussion on Dealing with dangling index pointers within the pgsql Hackers forums, part of the PostgreSQL category; --> While looking at the HOT patch, I noticed that if there's an index tuple pointing to a non-existing heap ...


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-15-2008, 09:01 PM
Heikki Linnakangas
 
Posts: n/a
Default Dealing with dangling index pointers

While looking at the HOT patch, I noticed that if there's an index tuple
pointing to a non-existing heap tuple, we just silently ignore it.

Such dangling index entries of course means that your database is
corrupt, but we ought to handle that better. In the worst case, the heap
slot is inserted to in the future, and then the bogus index entry points
to a wrong tuple.

ISTM we should print a warning suggesting a REINDEX, and kill the index
tuple. Killing tuples in the face of corruption is dangerous, but in
this case I think it's the right thing to do. We could also just emit
the warning, but that could fill the logs quickly if the index tuple is
accessed frequently.

--
Heikki Linnakangas
EnterpriseDB http://www.enterprisedb.com

---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
choose an index scan if your joining column's datatypes do not
match

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-15-2008, 09:01 PM
Tom Lane
 
Posts: n/a
Default Re: Dealing with dangling index pointers

Heikki Linnakangas <heikki@enterprisedb.com> writes:
> While looking at the HOT patch, I noticed that if there's an index tuple
> pointing to a non-existing heap tuple, we just silently ignore it.


This is intentional --- consider case where VACUUM has removed both
index and heap entries while some other (amazingly slow...) process is
in flight from the index to the heap.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 7: You can help support the PostgreSQL project by donating at

http://www.postgresql.org/about/donate

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-15-2008, 09:01 PM
Hannu Krosing
 
Posts: n/a
Default Re: Dealing with dangling index pointers

Ühel kenal päeval, E, 2007-07-16 kell 15:23, kirjutas Heikki
Linnakangas:
> While looking at the HOT patch, I noticed that if there's an index tuple
> pointing to a non-existing heap tuple, we just silently ignore it.
>
> Such dangling index entries of course means that your database is
> corrupt, but we ought to handle that better. In the worst case, the heap
> slot is inserted to in the future, and then the bogus index entry points
> to a wrong tuple.
>
> ISTM we should print a warning suggesting a REINDEX, and kill the index
> tuple. Killing tuples in the face of corruption is dangerous, but in
> this case I think it's the right thing to do. We could also just emit
> the warning, but that could fill the logs quickly if the index tuple is
> accessed frequently.


maybe issue a warning and set the DELETED index bit ?

marking the invalid pointer as deleted should make it effectively
disappear from use, without adding too much complexity

-------------
Hannu



---------------------------(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
  #4 (permalink)  
Old 04-15-2008, 09:01 PM
Heikki Linnakangas
 
Posts: n/a
Default Re: Dealing with dangling index pointers

Tom Lane wrote:
> Heikki Linnakangas <heikki@enterprisedb.com> writes:
>> While looking at the HOT patch, I noticed that if there's an index tuple
>> pointing to a non-existing heap tuple, we just silently ignore it.

>
> This is intentional --- consider case where VACUUM has removed both
> index and heap entries while some other (amazingly slow...) process is
> in flight from the index to the heap.


Hmm. In b-tree we keep the index page pinned while we do the heap fetch
to avoid that, but apparently we don't have that interlock in other
indexams.

Ok, never mind.

--
Heikki Linnakangas
EnterpriseDB http://www.enterprisedb.com

---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql.org so that your
message can get through to the mailing list cleanly

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 04-15-2008, 09:01 PM
Tom Lane
 
Posts: n/a
Default Re: Dealing with dangling index pointers

Heikki Linnakangas <heikki@enterprisedb.com> writes:
> Tom Lane wrote:
>> This is intentional --- consider case where VACUUM has removed both
>> index and heap entries while some other (amazingly slow...) process is
>> in flight from the index to the heap.


> Hmm. In b-tree we keep the index page pinned while we do the heap fetch
> to avoid that, but apparently we don't have that interlock in other
> indexams.


Right. This is actually connected to the fact that only btrees are used
as system catalog indexes, and so only btrees need to be safe for use
with SnapshotNow semantics. If VACUUM has managed to remove the target
tuple while we are "in flight", then it's further possible that someone
else has inserted something new into that same tuple slot, and maybe
even committed by the time we get there. Under SnapshotNow rules we
would take the new tuple as a valid search result, though it (probably)
doesn't actually satisfy the index search condition. With any MVCC-safe
snapshot we will reject the new tuple as not meeting the snapshot.

(BTW, this answers Teodor's question awhile back about whether he could
use a GIN index in a system catalog. Nope, not without more work on
index interlocking.)

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend

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 06:08 AM.


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