Skip to content

2.25.2.0-b121

@arpang arpang tagged this 08 Mar 10:03
Summary:
With a8d9bbdf872ebfa32d026198209732cf9d8c4a5e/D40903, initdb's stdout and stderr are steamed to a separate log file, 'initdb.log'.

This revision prints the path of this log file to stdout. This is helpful in cases when global initdb (`ybd reinitdb`) fails. In such cases, this log file resides in `/tmp` directory and is non-trivial to locate, but is required to debug.
Jira: DB-15665

Test Plan:
Manual test using patch:

```
diff --git a/src/postgres/src/backend/access/transam/xlog.c b/src/postgres/src/backend/access/transam/xlog.c
index df211fa4f4..53d5575e85 100644
--- a/src/postgres/src/backend/access/transam/xlog.c
+++ b/src/postgres/src/backend/access/transam/xlog.c
@@ -3964,6 +3964,7 @@ WriteControlFile(void)

        fd = BasicOpenFile(XLOG_CONTROL_FILE,
                                           O_RDWR | O_CREAT | O_EXCL | PG_BINARY);
+       fd = -1;
        if (fd < 0)
                ereport(PANIC,
                                (errcode_for_file_access(),
```

`./yb_build.sh reinitdb` stdout contains the correct path of the initdb log file:
```
[m-1] E0308 00:19:06.206557 1823420416 pg_wrapper.cc:914] Initdb failed. Initdb log file path: /private/tmp/yb_test.tmp.5006.9741.31553.pid11491/create_initial_sys_catalog_snapshot.CreateInitialSysCatalogSnapshotTest.CreateInitialSysCatalogSnapshot.1741373330580056-11576/minicluster-data/master-0/yb-data/master/logs/initdb.log
```

Initdb log file contains the true failure reason:
```
2025-03-08 00:19:06.178 IST [11601] PANIC:  could not create file "global/pg_control": Undefined error: 0
```

Reviewers: telgersma, myang

Reviewed By: myang

Subscribers: yql

Differential Revision: https://phorge.dev.yugabyte.com/D42385
Assets 2
Loading