Hi hackers, I intended for the temporary file name generated by basic_archive.c to include the current timestamp so that the name was "sufficiently unique." Of course, this could also be used to determine the creation time, but you can just as easily use stat(1) for that. In any case, I forgot to divide the microseconds field by 1000 to obtain the current timestamp in milliseconds, so while the value is unique, it's also basically garbage. I've attached a small patch that fixes this so that the temporary file name includes the timestamp in milliseconds for when it was created.
-- Nathan Bossart Amazon Web Services: https://aws.amazon.com
diff --git a/contrib/basic_archive/basic_archive.c b/contrib/basic_archive/basic_archive.c index 776a386e35..a02708fc12 100644 --- a/contrib/basic_archive/basic_archive.c +++ b/contrib/basic_archive/basic_archive.c @@ -265,7 +265,7 @@ basic_archive_file_internal(const char *file, const char *path) */ gettimeofday(&tv, NULL); if (pg_mul_u64_overflow((uint64) 1000, (uint64) tv.tv_sec, &epoch) || - pg_add_u64_overflow(epoch, (uint64) tv.tv_usec, &epoch)) + pg_add_u64_overflow(epoch, (uint64) tv.tv_usec / 1000, &epoch)) elog(ERROR, "could not generate temporary file name for archiving"); snprintf(temp, sizeof(temp), "%s/%s.%s.%d." UINT64_FORMAT,