Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit7c8d062

Browse files
committed
Merge branch 'REL9_5_STABLE' into PGPRO9_5
2 parents7951d67 +73f5acc commit7c8d062

File tree

7 files changed

+439
-322
lines changed

7 files changed

+439
-322
lines changed

‎src/backend/tcop/postgres.c

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2920,6 +2920,9 @@ ProcessInterrupts(void)
29202920

29212921
if (QueryCancelPending)
29222922
{
2923+
boollock_timeout_occurred;
2924+
boolstmt_timeout_occurred;
2925+
29232926
/*
29242927
* Don't allow query cancel interrupts while reading input from the
29252928
* client, because we might lose sync in the FE/BE protocol. (Die
@@ -2940,17 +2943,29 @@ ProcessInterrupts(void)
29402943

29412944
/*
29422945
* If LOCK_TIMEOUT and STATEMENT_TIMEOUT indicators are both set, we
2943-
*prefer toreport the former; but be sure to clear both.
2946+
*need toclear both, so always fetch both.
29442947
*/
2945-
if (get_timeout_indicator(LOCK_TIMEOUT, true))
2948+
lock_timeout_occurred=get_timeout_indicator(LOCK_TIMEOUT, true);
2949+
stmt_timeout_occurred=get_timeout_indicator(STATEMENT_TIMEOUT, true);
2950+
2951+
/*
2952+
* If both were set, we want to report whichever timeout completed
2953+
* earlier; this ensures consistent behavior if the machine is slow
2954+
* enough that the second timeout triggers before we get here. A tie
2955+
* is arbitrarily broken in favor of reporting a lock timeout.
2956+
*/
2957+
if (lock_timeout_occurred&&stmt_timeout_occurred&&
2958+
get_timeout_finish_time(STATEMENT_TIMEOUT)<get_timeout_finish_time(LOCK_TIMEOUT))
2959+
lock_timeout_occurred= false;/* report stmt timeout */
2960+
2961+
if (lock_timeout_occurred)
29462962
{
2947-
(void)get_timeout_indicator(STATEMENT_TIMEOUT, true);
29482963
LockErrorCleanup();
29492964
ereport(ERROR,
29502965
(errcode(ERRCODE_LOCK_NOT_AVAILABLE),
29512966
errmsg("canceling statement due to lock timeout")));
29522967
}
2953-
if (get_timeout_indicator(STATEMENT_TIMEOUT, true))
2968+
if (stmt_timeout_occurred)
29542969
{
29552970
LockErrorCleanup();
29562971
ereport(ERROR,

‎src/backend/utils/misc/timeout.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ typedef struct timeout_params
3434
timeout_handler_proctimeout_handler;
3535

3636
TimestampTzstart_time;/* time that timeout was last activated */
37-
TimestampTzfin_time;/*if active,time it is due to fire */
37+
TimestampTzfin_time;/* time it is, or was last, due to fire */
3838
}timeout_params;
3939

4040
/*
@@ -654,3 +654,17 @@ get_timeout_start_time(TimeoutId id)
654654
{
655655
returnall_timeouts[id].start_time;
656656
}
657+
658+
/*
659+
* Return the time when the timeout is, or most recently was, due to fire
660+
*
661+
* Note: will return 0 if timeout has never been activated in this process.
662+
* However, we do *not* reset the fin_time when a timeout occurs, so as
663+
* not to create a race condition if SIGALRM fires just as some code is
664+
* about to fetch the value.
665+
*/
666+
TimestampTz
667+
get_timeout_finish_time(TimeoutIdid)
668+
{
669+
returnall_timeouts[id].fin_time;
670+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp