Re: current_timestamp wrong

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: current_timestamp wrong
Дата
Msg-id 21818.998519174@sss.pgh.pa.us
обсуждение исходный текст
Ответ на current_timestamp wrong  (Peter Pilsl <pilsl@goldfisch.at>)
Ответы Re: current_timestamp wrong  (Peter Pilsl <pilsl@goldfisch.at>)
Список pgsql-general
Peter Pilsl <pilsl@goldfisch.at> writes:
> In a bigger perl-project I had to hunt down a bug and it turned out that on
> very rare occassions the time delivered by 'current_timestamp'
> is wrong by a noticeable amount of time. (up to hours sometimes)

> The problem occures when using the DBI-module for perl and mod_perl in
> apache and the db-handle is stored globally for hours. On the first
> call for current_timestamp after long idle-time the returned value is
> *sometimes* incorrect.

current_timestamp is defined as the time of the start of the current
transaction (this is not a bug, it's a feature).

If your program is set up to hold a transaction open while it's idle,
that could cause stale-looking values of current_timestamp when you
finally do something in the transaction.  Unfortunately I believe that
"autocommit off" mode in the DBD driver does exactly that.

This could possibly be fixed by altering the DBD driver so that after
it's issued COMMIT or ROLLBACK, it doesn't instantly send a BEGIN,
but delays sending BEGIN until it's actually asked to issue a query.
I have not looked at the code to see how hard it'd be to do that.

            regards, tom lane

В списке pgsql-general по дате отправления:

Предыдущее
От: Stephan Szabo
Дата:
Сообщение: Re: current_timestamp wrong
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Error reporting when hitting shared memory limits -