pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Jochem van Dieten <jochemd@oli.tudelft.nl>
To: mkoi-pg@aon.at
Cc: tgl@sss.pgh.pa.us
Cc: pgsql-performance@postgresql.org
Subject: Re: planner/optimizer question
Date: Sun, 2 May 2004 16:30:47 +0200 (CEST)
Message-ID: <1529.130.161.199.221.1083508247.squirrel@secure.oli.tudelft.nl> (raw)
In-Reply-To: <ra9990hea0ats52frhjd6u0c5dsbr7jkmd@email.aon.at>
References: <pvc290584alms4s6hurvsh5ra09ki7se1s@email.aon.at>
	<409290F0.10509@oli.tudelft.nl>
	<toe590tgu39ilahg3p1os2mjlgf4iss582@email.aon.at>
	<8881.1083374379@sss.pgh.pa.us>
	<4093876C.2060409@oli.tudelft.nl>
	<ra9990hea0ats52frhjd6u0c5dsbr7jkmd@email.aon.at>

Manfred Koizar said:
>
> As Tom has explained in a nearby message his concern is that --
> unlike dead-to-all -- visible-to-all starts as false, is set to true
> at some point in time, and is eventually set to false again.
> Problems arise if one backend wants to set visible-to-all to true
> while at the same time another backend wants to set it to false.

Got it, I misinterpreted his concern as "visible-to-all should not be
set to true when the tuple is inserted".


> This could be curable by using a second bit as a deleted flag (might
> be even the same bit that's now used as dead-to-all, but I'm not
> sure).  An index tuple having both the visible flag (formerly called
> visible-to-all) and the deleted flag set would cause a heap tuple
> access to check visibility.

Or in a more generalized way: with 2 bits written at the same time you
can express 4 states. But only 3 actions need to be signalled:
dead-to-all, visible-to-all and check-heap. So we can have 2 states
that both signal check-heap.

The immediate solution to the race condition Tom presented would be to
have the transaction that invalidates the heap tuple switch the index
tuple from the one check-heap state to the other. The transaction that
wants to update to visible-to-all can now see that the state has
changed (but not the meaning) and aborts its change.


> But that leaves the question of what to
> do after the deleting transaction has rolled back.  I see no clean
> way from the visible-and-deleted state to visible-to-all.

I'm afraid I don't know enough about the inner workings of rollbacks
to determine how the scenario "A determines visible-to-all should be
set, B invalidates tuple, B rolls back, C invalidates tuple, C
commits, A reaquires lock on index" would work out. I guess I have
some more reading to do.

But if you don't roll back too often it wouldn't even be a huge
problem to just leave them in visible-and-deleted state until
eventually they go into the dead-to-all state.

Jochem







view thread (37+ messages)

Message-ID: <1529.130.161.199.221.1083508247.squirrel@secure.oli.tudelft.nl>
Permalink:  ../1529.130.161.199.221.1083508247.squirrel@secure.oli.tudelft.nl/
Also on:    postgresql.org/message-id/1529.130.161.199.221.1083508247.squirrel@secure.oli.tudelft.nl

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-performance@postgresql.org
  Cc: jochemd@oli.tudelft.nl, mkoi-pg@aon.at, tgl@sss.pgh.pa.us
  Subject: Re: planner/optimizer question
  In-Reply-To: <1529.130.161.199.221.1083508247.squirrel@secure.oli.tudelft.nl>
  References: <pvc290584alms4s6hurvsh5ra09ki7se1s@email.aon.at> <409290F0.10509@oli.tudelft.nl> <toe590tgu39ilahg3p1os2mjlgf4iss582@email.aon.at> <8881.1083374379@sss.pgh.pa.us> <4093876C.2060409@oli.tudelft.nl> <ra9990hea0ats52frhjd6u0c5dsbr7jkmd@email.aon.at> <1529.130.161.199.221.1083508247.squirrel@secure.oli.tudelft.nl>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox