Re: Are we accepting cancel interrupts too often?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Are we accepting cancel interrupts too often?
Date: 2001-12-31 16:32:57
Message-ID: 13246.1009816377@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> writes:
> I started to look at when this nice code was added to determine if this
> was part of the original design or added later and found you wrote it
> yourself, so I guess we don't have to ask anyone to make sure there
> isn't something were are missing.

As far as I can recall my thinking at the time, it went like so:
"We *should* be able to accept a cancel interrupt anywhere we are not
actually in the midst of modifying shared-memory data structures,
because after all the database system is supposed to be robust against
crashes, and those could happen anyplace".

But the fallacy in equating a cancel to a crash is that we have rather
extensive logic for coping with a crash (including reinitializing shared
memory from scratch). A cancel will only provoke elog cleanup, which is
not nearly as thorough. For example, it's not obvious that shared
memory structures that are protected by different locks couldn't get out
of sync.

BTW, I spent some time yesterday trying to use this worry to explain my
latest favorite bugaboo, the duplicate-rows complaints we've gotten from
a few people. It is easy to see that a cancel being accepted at the
right place (exit from the first WriteBuffer in heap_update) could leave
an updated tuple created and its buffer marked dirty, while the old
tuple's buffer is not yet marked dirty and might therefore be discarded
unwritten. (The WAL entry is correct but will never be consulted unless
there's a crash.) However, this scenario doesn't seem to explain the
failures because the cancel would lead to transaction abort, so the
updated tuple should never be considered good anyway. Back to the
drawing board...

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2001-12-31 16:41:56 Re: Are we accepting cancel interrupts too often?
Previous Message wsheldah 2001-12-31 16:18:50 Re: date/time formats in 7.2