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

Commitd038966

Browse files
committed
Fix syslogger to not fail when log_rotation_age exceeds 2^31 milliseconds.
We need to avoid calling WaitLatch with timeouts exceeding INT_MAX.Fortunately a simple clamp will do the trick, since no harm is done ifthe wait times out before it's really time to rotate the log file.Per bug #7670 (probably bug #7545 is the same thing, too).In passing, fix bogus definition of log_rotation_age's maximum value inguc.c --- it was numerically right, but only because MINS_PER_HOUR andSECS_PER_MINUTE have the same value.Back-patch to 9.2. Before that, syslogger wasn't using WaitLatch.
1 parent14ddff4 commitd038966

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

‎src/backend/postmaster/syslogger.c

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include"postgres.h"
2525

2626
#include<fcntl.h>
27+
#include<limits.h>
2728
#include<signal.h>
2829
#include<time.h>
2930
#include<unistd.h>
@@ -416,11 +417,23 @@ SysLoggerMain(int argc, char *argv[])
416417
* above is still close enough. Note we can't make this calculation
417418
* until after calling logfile_rotate(), since it will advance
418419
* next_rotation_time.
420+
*
421+
* Also note that we need to beware of overflow in calculation of the
422+
* timeout: with large settings of Log_RotationAge, next_rotation_time
423+
* could be more than INT_MAX msec in the future. In that case we'll
424+
* wait no more than INT_MAX msec, and try again.
419425
*/
420426
if (Log_RotationAge>0&& !rotation_disabled)
421427
{
422-
if (now<next_rotation_time)
423-
cur_timeout= (next_rotation_time-now)*1000L;/* msec */
428+
pg_time_tdelay;
429+
430+
delay=next_rotation_time-now;
431+
if (delay>0)
432+
{
433+
if (delay>INT_MAX /1000)
434+
delay=INT_MAX /1000;
435+
cur_timeout=delay*1000L;/* msec */
436+
}
424437
else
425438
cur_timeout=0;
426439
cur_flags=WL_TIMEOUT;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2147,7 +2147,7 @@ static struct config_int ConfigureNamesInt[] =
21472147
GUC_UNIT_MIN
21482148
},
21492149
&Log_RotationAge,
2150-
HOURS_PER_DAY*MINS_PER_HOUR,0,INT_MAX /MINS_PER_HOUR,
2150+
HOURS_PER_DAY*MINS_PER_HOUR,0,INT_MAX /SECS_PER_MINUTE,
21512151
NULL,NULL,NULL
21522152
},
21532153

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp