Skip to content

Commit c68a183

Browse files
committedOct 17, 2022
Fix calculation related to temporary WAL segment name in basic_archive
The file name used for its temporary destination, before renaming it to the real deal, has been using a microseconds in a timestamp aimed to be originally in milli-seconds. This is harmless as this is aimed at being a safeguard against name collisions (note MyProcPid in the name), but let's be correct with the maths. While on it, add a note in the module's makefile to document why installcheck is not supported. Author: Nathan Bossart Reviewed-by: Bharath Rupireddy Discussion: https://postgr.es/m/20221014044106.GA1673343@nathanxps13 Backpatch-through: 15
1 parent 7622422 commit c68a183

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed
 

‎contrib/basic_archive/Makefile

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ PGFILEDESC = "basic_archive - basic archive module"
55

66
REGRESS = basic_archive
77
REGRESS_OPTS = --temp-config $(top_srcdir)/contrib/basic_archive/basic_archive.conf
8-
8+
# Disabled because these tests require "shared_preload_libraries=basic_archive",
9+
# which typical installcheck users do not have (e.g. buildfarm clients).
910
NO_INSTALLCHECK = 1
1011

1112
ifdef USE_PGXS

‎contrib/basic_archive/basic_archive.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ basic_archive_file_internal(const char *file, const char *path)
218218
char temp[MAXPGPATH + 256];
219219
struct stat st;
220220
struct timeval tv;
221-
uint64 epoch;
221+
uint64 epoch; /* milliseconds */
222222

223223
ereport(DEBUG3,
224224
(errmsg("archiving \"%s\" via basic_archive", file)));
@@ -265,7 +265,7 @@ basic_archive_file_internal(const char *file, const char *path)
265265
*/
266266
gettimeofday(&tv, NULL);
267267
if (pg_mul_u64_overflow((uint64) 1000, (uint64) tv.tv_sec, &epoch) ||
268-
pg_add_u64_overflow(epoch, (uint64) tv.tv_usec, &epoch))
268+
pg_add_u64_overflow(epoch, (uint64) (tv.tv_usec / 1000), &epoch))
269269
elog(ERROR, "could not generate temporary file name for archiving");
270270

271271
snprintf(temp, sizeof(temp), "%s/%s.%s.%d." UINT64_FORMAT,

0 commit comments

Comments
 (0)
Please sign in to comment.