Hi. Here are some review comments for v18-0001.

======

1.
+#define SERVER_LOG_FILE_NAME "pg_createsubscriber_server"
+#define INTERNAL_LOG_FILE_NAME "pg_createsubscriber_internal"

Those are not the names of logfiles; they are just the first part of
the names. Why not also put the ".log" part here, instead of burying
it in format strings scattered in the code?

SUGGESTION (e.g., more similar to pg_upgrade.h)
#define SERVER_LOG_FILE_NAME "pg_createsubscriber_server.log"
#define INTERNAL_LOG_FILE_NAME "pg_createsubscriber_internal.log"

~~~

2.
+static char logdir[MAXPGPATH]; /* Directory log files are put (if specified) */

Missing words in that comment?

e.g.
Directory where log files are written ...
Directory for log files ...

It might also be useful to mention that this is more than just the
original user-specified --logdir directory; it also includes the
timestamp sub-dir.

~~~

3.
 /*
- * Report a message with a given log level
+ * Report a message with a given log level to stderr and log file
+ * (if specified).
  */
+static void
+report_createsub_log_v(enum pg_log_level level, enum pg_log_part part,
+    const char *pg_restrict fmt, va_list args)

This is a function comment, but there is no way to specify the log
file by using this function, so maybe reword that "if specified" part
for clarity.

SUGGESTION:
* Report a message with a given log level.
* Writes to stderr, and also to the log file (if pg_createsubscriber
--logdir option was specified).

~~~

4.
+ /* Build timestamp directory path */
+ len = snprintf(logdir, MAXPGPATH, "%s/%s", log_basedir, timestamp);
+
+ if (len >= MAXPGPATH)
+ report_createsub_fatal("directory path for log files, %s/%s, is too long",
+    logdir, timestamp);

IIUC, when the snprintf exceeds MAXPGPATH, then 'logdir' is going to
contain a truncated string. And, maybe that already includes a partial
truncated timestamp part:
"myreallylongname/20260"

AFAICT, the subsequent fatal message is going to report that
incorrectly when it appends the timestamp a second time, like:
"... myreallylongname/20260/20260119T204317.204 is too long"

Notice that pg_upgrade doesn't try to report the names of files that
are too long. It just says things like "directory path for new cluster
is too long".

======
Kind Regards,
Peter Smith.
Fujitsu Australia


Reply via email to