Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit d4c3a6b

Browse files
committed
Remove obsolete restriction on the range of log_rotation_size.
When syslogger.c was first written, we didn't want to assume that all platforms have 64-bit ftello. But we've been assuming that since v13 (cf commit 799d224), so let's use that in syslogger.c and allow log_rotation_size to range up to INT_MAX kilobytes. The old code effectively limited log_rotation_size to 2GB regardless of platform. While nobody's complained, that doesn't seem too far away from what might be thought reasonable these days. I noticed this while searching for instances of "1024L" in connection with commit 041e8b9. These were the last such instances. (We still have instances of L-suffixed literals, but most of them are associated with wait intervals for pg_usleep or similar functions. I don't see any urgent reason to change that.)
1 parent 041e8b9 commit d4c3a6b

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

src/backend/postmaster/syslogger.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -444,19 +444,19 @@ SysLoggerMain(char *startup_data, size_t startup_data_len)
444444
if (!rotation_requested && Log_RotationSize > 0 && !rotation_disabled)
445445
{
446446
/* Do a rotation if file is too big */
447-
if (ftell(syslogFile) >= Log_RotationSize * 1024L)
447+
if (ftello(syslogFile) >= Log_RotationSize * (pgoff_t) 1024)
448448
{
449449
rotation_requested = true;
450450
size_rotation_for |= LOG_DESTINATION_STDERR;
451451
}
452452
if (csvlogFile != NULL &&
453-
ftell(csvlogFile) >= Log_RotationSize * 1024L)
453+
ftello(csvlogFile) >= Log_RotationSize * (pgoff_t) 1024)
454454
{
455455
rotation_requested = true;
456456
size_rotation_for |= LOG_DESTINATION_CSVLOG;
457457
}
458458
if (jsonlogFile != NULL &&
459-
ftell(jsonlogFile) >= Log_RotationSize * 1024L)
459+
ftello(jsonlogFile) >= Log_RotationSize * (pgoff_t) 1024)
460460
{
461461
rotation_requested = true;
462462
size_rotation_for |= LOG_DESTINATION_JSONLOG;
@@ -1183,9 +1183,11 @@ pipeThread(void *arg)
11831183
*/
11841184
if (Log_RotationSize > 0)
11851185
{
1186-
if (ftell(syslogFile) >= Log_RotationSize * 1024L ||
1187-
(csvlogFile != NULL && ftell(csvlogFile) >= Log_RotationSize * 1024L) ||
1188-
(jsonlogFile != NULL && ftell(jsonlogFile) >= Log_RotationSize * 1024L))
1186+
if (ftello(syslogFile) >= Log_RotationSize * (pgoff_t) 1024 ||
1187+
(csvlogFile != NULL &&
1188+
ftello(csvlogFile) >= Log_RotationSize * (pgoff_t) 1024) ||
1189+
(jsonlogFile != NULL &&
1190+
ftello(jsonlogFile) >= Log_RotationSize * (pgoff_t) 1024))
11891191
SetLatch(MyLatch);
11901192
}
11911193
LeaveCriticalSection(&sysloggerSection);

src/backend/utils/misc/guc_tables.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3299,7 +3299,7 @@ struct config_int ConfigureNamesInt[] =
32993299
GUC_UNIT_KB
33003300
},
33013301
&Log_RotationSize,
3302-
10 * 1024, 0, INT_MAX / 1024,
3302+
10 * 1024, 0, INT_MAX,
33033303
NULL, NULL, NULL
33043304
},
33053305

0 commit comments

Comments
 (0)