Re: [PATCH] lock_timeout and common SIGALRM framework - Mailing list pgsql-hackers

From Tom Lane
Subject Re: [PATCH] lock_timeout and common SIGALRM framework
Date
Msg-id 26321.1342216171@sss.pgh.pa.us
Whole thread Raw
In response to Re: [PATCH] lock_timeout and common SIGALRM framework  (Boszormenyi Zoltan <zb@cybertec.at>)
List pgsql-hackers
Boszormenyi Zoltan <zb@cybertec.at> writes:
> It means that StatementTimeout losts its precision. It would trigger
> in the future counting from "now" instead of counting from
> GetCurrentStatementStartTimestamp().

That is, in fact, better not worse.  Note the comment in the existing
code:
        * Begin statement-level timeout        *        * Note that we compute statement_fin_time with reference to the
      * statement_timestamp, but apply the specified delay without any        * correction; that is, we ignore whatever
timehas elapsed since        * statement_timestamp was set.  In the normal case only a small        * interval will
haveelapsed and so this doesn't matter, but there        * are corner cases (involving multi-statement query strings
with       * embedded COMMIT or ROLLBACK) where we might re-initialize the        * statement timeout long after
initialreceipt of the message. In        * such cases the enforcement of the statement timeout will be a bit        *
inconsistent. This annoyance is judged not worth the cost of        * performing an additional gettimeofday() here.
 

That is, measuring from GetCurrentStatementStartTimestamp is a hack to
save one gettimeofday call, at the cost of making the timeout less
accurate, sometimes significantly so.  In the new model there isn't any
good way to duplicate this kluge (in particular, there's no point in
using enable_timeout_at, because that will still make a gettimeofday
call).  That doesn't bother me too much.  I'd rather try to buy back
whatever performance was lost by seeing if we can reduce the number of
setitimer calls.
        regards, tom lane


pgsql-hackers by date:

Previous
From: Jeff Davis
Date:
Subject: Re: initdb and fsync
Next
From: Tom Lane
Date:
Subject: Re: [PATCH] lock_timeout and common SIGALRM framework