Re: Interesting tight loop - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Interesting tight loop
Date
Msg-id 28400.1158242047@sss.pgh.pa.us
Whole thread Raw
In response to Interesting tight loop  (Theo Schlossnagle <jesus@omniti.com>)
List pgsql-hackers
Theo Schlossnagle <jesus@omniti.com> writes:
> In production today (8.1.4), I ran into a backend process that  
> wouldn't cancel right away -- minutes went by.

> It was in

> [0] TransactionIdIsCurrentTransactionId
> [1] HeapTupleSatisfiesSnapshot
> ...

> But the interesting thing is that there were 4.6 million elements in  
> the s->childXids list.  Which is why it took so damn long.

Well, I don't think TransactionIdIsCurrentTransactionId() itself is to
blame --- the loop over childXids is about as tight as such a loop could
possibly be (two indirect fetches and a comparison per iteration).
Even with 4.6M child Xids it could hardly take a second on any modern
machine.  I'm not inclined to add a CHECK_FOR_INTERRUPTS there.  The
problem should instead be blamed on something further down the call
stack ... did you save the full stack by any chance?
        regards, tom lane


pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: CSStorm occurred again by postgreSQL8.2
Next
From: Tom Lane
Date:
Subject: Re: CSStorm occurred again by postgreSQL8.2