Starting posgresql on a new terminal window fails #18860

Closed
opened 2026-01-31 06:26:26 +00:00 by claunia · 2 comments
Owner

Originally created by @brunomlopes on GitHub (Nov 10, 2022).

Originally assigned to: @lhecker on GitHub.

Windows Terminal version

1.15.2875.0

Windows build number

10.0.22000.1219

Other Software

PostgreSQL for Windows, tested on 15.0-1 (for extra logging) and 9.3.4.3 , taken from https://www.enterprisedb.com/download-postgresql-binaries

Steps to reproduce

The steps are:

  • get the postgresql binaries and initialize the database
  • set windows terminal as the default terminal on windows
  • launch pg_ctl.exe to start postgres with start so that it runs on a new window

I have added repro steps below, for windows terminal on new window (fails), on current window (works), conhost on new window (works) conhost on current window (works).

The commands to start and stop write to a logfile names start-log-outside.log on the current folder.

Download the postgres binaries and initialize it. I decompressed the binaries into a tools folder .

To initialize:

. \tools\bin\initdb.exe -D .\data -E UTF8 -U "postgres"

With Windows Terminal set as default terminal on windows:

started with

start cmd /c ".\tools\bin\pg_ctl.exe -D .\data\ -l .\start-log-outside.log start"

so that it opens in a new tab

The log on start-log-outside.log shows that postgres fails to start

2022-11-10 12:55:56.188 GMT [33936] LOG: starting PostgreSQL 15.0, compiled by Visual C++ build 1914, 64-bit
2022-11-10 12:55:56.193 GMT [33936] LOG: listening on IPv6 address "::1", port 5432
2022-11-10 12:55:56.193 GMT [33936] LOG: listening on IPv4 address "127.0.0.1", port 5432
2022-11-10 12:55:56.264 GMT [55704] LOG: database system was interrupted; last known up at 2022-11-10 12:55:33 GMT
2022-11-10 12:55:56.832 GMT [55704] LOG: database system was not properly shut down; automatic recovery in progress
2022-11-10 12:55:56.839 GMT [55704] LOG: invalid record length at 0/A438390: wanted 24, got 0
2022-11-10 12:55:56.839 GMT [55704] LOG: redo is not required
2022-11-10 12:55:56.848 GMT [37748] LOG: checkpoint starting: end-of-recovery immediate wait
2022-11-10 12:55:56.855 GMT [37748] LOG: checkpoint complete: wrote 3 buffers (0.0%); 0 WAL file(s) added, 0 removed, 0 recycled; write=0.002 s, sync=0.002 s, total=0.009 s; sync files=2, longest=0.001 s, average=0.001 s; distance=0 kB, estimate=0 kB
2022-11-10 12:55:56.869 GMT [33936] LOG: database system is ready to accept connections
2022-11-10 12:55:56.960 GMT [33936] LOG: background worker "logical replication launcher" (PID 4492) was terminated by exception 0xC000013A
2022-11-10 12:55:56.960 GMT [33936] HINT: See C include file "ntstatus.h" for a description of the hexadecimal value.
2022-11-10 12:55:56.961 GMT [33936] LOG: terminating any other active server processes
2022-11-10 12:55:56.966 GMT [33936] LOG: received fast shutdown request
^C

The ^C is included in the log file

Starting regularly shows database ready and no issues:

cmd /c ".\tools\bin\pg_ctl.exe -D .\data\ -l .\start-log-outside.log start"

2022-11-10 12:54:07.610 GMT [14120] LOG: starting PostgreSQL 15.0, compiled by Visual C++ build 1914, 64-bit
2022-11-10 12:54:07.618 GMT [14120] LOG: listening on IPv6 address "::1", port 5432
2022-11-10 12:54:07.618 GMT [14120] LOG: listening on IPv4 address "127.0.0.1", port 5432
2022-11-10 12:54:07.691 GMT [50900] LOG: database system was shut down at 2022-11-10 12:53:34 GMT
2022-11-10 12:54:07.723 GMT [14120] LOG: database system is ready to accept connections

stopped with

cmd /c ".\tools\bin\pg_ctl.exe -D .\data\ -l .\start-log-outside.log start"

2022-11-10 12:54:26.988 GMT [14120] LOG: received fast shutdown request
2022-11-10 12:54:27.017 GMT [14120] LOG: aborting any active transactions
2022-11-10 12:54:27.021 GMT [14120] LOG: background worker "logical replication launcher" (PID 33376) exited with exit code 1
2022-11-10 12:54:27.022 GMT [42576] LOG: shutting down
2022-11-10 12:54:27.023 GMT [42576] LOG: checkpoint starting: shutdown immediate
2022-11-10 12:54:27.032 GMT [42576] LOG: checkpoint complete: wrote 3 buffers (0.0%); 0 WAL file(s) added, 0 removed, 0 recycled; write=0.002 s, sync=0.002 s, total=0.010 s; sync files=2, longest=0.001 s, average=0.001 s; distance=0 kB, estimate=0 kB
2022-11-10 12:54:27.038 GMT [14120] LOG: database system is shut down

With Windows console host set as default terminal on windows (all work):

start cmd /c ".\tools\bin\pg_ctl.exe -D .\data\ -l .\start-log-outside.log start"

2022-11-10 12:57:26.526 GMT [48928] LOG: starting PostgreSQL 15.0, compiled by Visual C++ build 1914, 64-bit
2022-11-10 12:57:26.533 GMT [48928] LOG: listening on IPv6 address "::1", port 5432
2022-11-10 12:57:26.533 GMT [48928] LOG: listening on IPv4 address "127.0.0.1", port 5432
2022-11-10 12:57:26.633 GMT [41624] LOG: database system was interrupted; last known up at 2022-11-10 12:55:56 GMT
2022-11-10 12:57:27.200 GMT [41624] LOG: database system was not properly shut down; automatic recovery in progress
2022-11-10 12:57:27.206 GMT [41624] LOG: invalid record length at 0/A438408: wanted 24, got 0
2022-11-10 12:57:27.206 GMT [41624] LOG: redo is not required
2022-11-10 12:57:27.215 GMT [14988] LOG: checkpoint starting: end-of-recovery immediate wait
2022-11-10 12:57:27.222 GMT [14988] LOG: checkpoint complete: wrote 3 buffers (0.0%); 0 WAL file(s) added, 0 removed, 0 recycled; write=0.002 s, sync=0.002 s, total=0.010 s; sync files=2, longest=0.001 s, average=0.001 s; distance=0 kB, estimate=0 kB
2022-11-10 12:57:27.236 GMT [48928] LOG: database system is ready to accept connections

start cmd /c ".\tools\bin\pg_ctl.exe -D .\data\ -l .\start-log-outside.log stop"

2022-11-10 12:58:47.779 GMT [48928] LOG: received fast shutdown request
2022-11-10 12:58:47.791 GMT [48928] LOG: aborting any active transactions
2022-11-10 12:58:47.798 GMT [48928] LOG: background worker "logical replication launcher" (PID 27328) exited with exit code 1
2022-11-10 12:58:47.799 GMT [14988] LOG: shutting down
2022-11-10 12:58:47.800 GMT [14988] LOG: checkpoint starting: shutdown immediate
2022-11-10 12:58:47.807 GMT [14988] LOG: checkpoint complete: wrote 0 buffers (0.0%); 0 WAL file(s) added, 0 removed, 0 recycled; write=0.001 s, sync=0.001 s, total=0.009 s; sync files=0, longest=0.000 s, average=0.000 s; distance=0 kB, estimate=0 kB
2022-11-10 12:58:47.814 GMT [48928] LOG: database system is shut down

cmd /c ".\tools\bin\pg_ctl.exe -D .\data\ -l .\start-log-outside.log start"

2022-11-10 13:04:40.239 GMT [49696] LOG: starting PostgreSQL 15.0, compiled by Visual C++ build 1914, 64-bit
2022-11-10 13:04:40.245 GMT [49696] LOG: listening on IPv6 address "::1", port 5432
2022-11-10 13:04:40.245 GMT [49696] LOG: listening on IPv4 address "127.0.0.1", port 5432
2022-11-10 13:04:40.315 GMT [17204] LOG: database system was interrupted; last known up at 2022-11-10 13:00:13 GMT
2022-11-10 13:04:40.869 GMT [17204] LOG: database system was not properly shut down; automatic recovery in progress
2022-11-10 13:04:40.875 GMT [17204] LOG: invalid record length at 0/A438530: wanted 24, got 0
2022-11-10 13:04:40.875 GMT [17204] LOG: redo is not required
2022-11-10 13:04:40.887 GMT [40444] LOG: checkpoint starting: end-of-recovery immediate wait
2022-11-10 13:04:40.895 GMT [40444] LOG: checkpoint complete: wrote 3 buffers (0.0%); 0 WAL file(s) added, 0 removed, 0 recycled; write=0.002 s, sync=0.002 s, total=0.013 s; sync files=2, longest=0.001 s, average=0.001 s; distance=0 kB, estimate=0 kB
2022-11-10 13:04:40.909 GMT [49696] LOG: database system is ready to accept connections

cmd /c ".\tools\bin\pg_ctl.exe -D .\data\ -l .\start-log-outside.log stop"

2022-11-10 13:04:50.341 GMT [49696] LOG: received fast shutdown request
2022-11-10 13:04:50.363 GMT [49696] LOG: aborting any active transactions
2022-11-10 13:04:50.368 GMT [49696] LOG: background worker "logical replication launcher" (PID 48012) exited with exit code 1
2022-11-10 13:04:50.368 GMT [40444] LOG: shutting down
2022-11-10 13:04:50.369 GMT [40444] LOG: checkpoint starting: shutdown immediate
2022-11-10 13:04:50.375 GMT [40444] LOG: checkpoint complete: wrote 0 buffers (0.0%); 0 WAL file(s) added, 0 removed, 0 recycled; write=0.001 s, sync=0.001 s, total=0.008 s; sync files=0, longest=0.000 s, average=0.000 s; distance=0 kB, estimate=0 kB
2022-11-10 13:04:50.380 GMT [49696] LOG: database system is shut down

Expected Behavior

Starting pg_ctl on a new terminal window should work and postgres should stay up
Starting pg_ctl on the current terminal should work and postgres should stay up

Actual Behavior

Starting pg_ctl on a new terminal window causes postgres to fail to start
Starting pg_ctl on the current terminal window works.

Originally created by @brunomlopes on GitHub (Nov 10, 2022). Originally assigned to: @lhecker on GitHub. ### Windows Terminal version 1.15.2875.0 ### Windows build number 10.0.22000.1219 ### Other Software PostgreSQL for Windows, tested on 15.0-1 (for extra logging) and 9.3.4.3 , taken from https://www.enterprisedb.com/download-postgresql-binaries ### Steps to reproduce The steps are: - get the postgresql binaries and initialize the database - set windows terminal as the default terminal on windows - launch pg_ctl.exe to start postgres with `start` so that it runs on a new window I have added repro steps below, for windows terminal on new window (fails), on current window (works), conhost on new window (works) conhost on current window (works). The commands to start and stop write to a logfile names `start-log-outside.log` on the current folder. Download the postgres binaries and initialize it. I decompressed the binaries into a `tools` folder . To initialize: ``` . \tools\bin\initdb.exe -D .\data -E UTF8 -U "postgres" ``` With Windows Terminal set as default terminal on windows: started with ``` start cmd /c ".\tools\bin\pg_ctl.exe -D .\data\ -l .\start-log-outside.log start" ``` so that it opens in a new tab The log on `start-log-outside.log` shows that postgres fails to start 2022-11-10 12:55:56.188 GMT [33936] LOG: starting PostgreSQL 15.0, compiled by Visual C++ build 1914, 64-bit 2022-11-10 12:55:56.193 GMT [33936] LOG: listening on IPv6 address "::1", port 5432 2022-11-10 12:55:56.193 GMT [33936] LOG: listening on IPv4 address "127.0.0.1", port 5432 2022-11-10 12:55:56.264 GMT [55704] LOG: database system was interrupted; last known up at 2022-11-10 12:55:33 GMT 2022-11-10 12:55:56.832 GMT [55704] LOG: database system was not properly shut down; automatic recovery in progress 2022-11-10 12:55:56.839 GMT [55704] LOG: invalid record length at 0/A438390: wanted 24, got 0 2022-11-10 12:55:56.839 GMT [55704] LOG: redo is not required 2022-11-10 12:55:56.848 GMT [37748] LOG: checkpoint starting: end-of-recovery immediate wait 2022-11-10 12:55:56.855 GMT [37748] LOG: checkpoint complete: wrote 3 buffers (0.0%); 0 WAL file(s) added, 0 removed, 0 recycled; write=0.002 s, sync=0.002 s, total=0.009 s; sync files=2, longest=0.001 s, average=0.001 s; distance=0 kB, estimate=0 kB 2022-11-10 12:55:56.869 GMT [33936] LOG: database system is ready to accept connections 2022-11-10 12:55:56.960 GMT [33936] LOG: background worker "logical replication launcher" (PID 4492) was terminated by exception 0xC000013A 2022-11-10 12:55:56.960 GMT [33936] HINT: See C include file "ntstatus.h" for a description of the hexadecimal value. 2022-11-10 12:55:56.961 GMT [33936] LOG: terminating any other active server processes 2022-11-10 12:55:56.966 GMT [33936] LOG: received fast shutdown request ^C The ^C is included in the log file Starting regularly shows database ready and no issues: ``` cmd /c ".\tools\bin\pg_ctl.exe -D .\data\ -l .\start-log-outside.log start" ``` 2022-11-10 12:54:07.610 GMT [14120] LOG: starting PostgreSQL 15.0, compiled by Visual C++ build 1914, 64-bit 2022-11-10 12:54:07.618 GMT [14120] LOG: listening on IPv6 address "::1", port 5432 2022-11-10 12:54:07.618 GMT [14120] LOG: listening on IPv4 address "127.0.0.1", port 5432 2022-11-10 12:54:07.691 GMT [50900] LOG: database system was shut down at 2022-11-10 12:53:34 GMT 2022-11-10 12:54:07.723 GMT [14120] LOG: database system is ready to accept connections stopped with ``` cmd /c ".\tools\bin\pg_ctl.exe -D .\data\ -l .\start-log-outside.log start" ``` 2022-11-10 12:54:26.988 GMT [14120] LOG: received fast shutdown request 2022-11-10 12:54:27.017 GMT [14120] LOG: aborting any active transactions 2022-11-10 12:54:27.021 GMT [14120] LOG: background worker "logical replication launcher" (PID 33376) exited with exit code 1 2022-11-10 12:54:27.022 GMT [42576] LOG: shutting down 2022-11-10 12:54:27.023 GMT [42576] LOG: checkpoint starting: shutdown immediate 2022-11-10 12:54:27.032 GMT [42576] LOG: checkpoint complete: wrote 3 buffers (0.0%); 0 WAL file(s) added, 0 removed, 0 recycled; write=0.002 s, sync=0.002 s, total=0.010 s; sync files=2, longest=0.001 s, average=0.001 s; distance=0 kB, estimate=0 kB 2022-11-10 12:54:27.038 GMT [14120] LOG: database system is shut down With Windows console host set as default terminal on windows (all work): ``` start cmd /c ".\tools\bin\pg_ctl.exe -D .\data\ -l .\start-log-outside.log start" ``` 2022-11-10 12:57:26.526 GMT [48928] LOG: starting PostgreSQL 15.0, compiled by Visual C++ build 1914, 64-bit 2022-11-10 12:57:26.533 GMT [48928] LOG: listening on IPv6 address "::1", port 5432 2022-11-10 12:57:26.533 GMT [48928] LOG: listening on IPv4 address "127.0.0.1", port 5432 2022-11-10 12:57:26.633 GMT [41624] LOG: database system was interrupted; last known up at 2022-11-10 12:55:56 GMT 2022-11-10 12:57:27.200 GMT [41624] LOG: database system was not properly shut down; automatic recovery in progress 2022-11-10 12:57:27.206 GMT [41624] LOG: invalid record length at 0/A438408: wanted 24, got 0 2022-11-10 12:57:27.206 GMT [41624] LOG: redo is not required 2022-11-10 12:57:27.215 GMT [14988] LOG: checkpoint starting: end-of-recovery immediate wait 2022-11-10 12:57:27.222 GMT [14988] LOG: checkpoint complete: wrote 3 buffers (0.0%); 0 WAL file(s) added, 0 removed, 0 recycled; write=0.002 s, sync=0.002 s, total=0.010 s; sync files=2, longest=0.001 s, average=0.001 s; distance=0 kB, estimate=0 kB 2022-11-10 12:57:27.236 GMT [48928] LOG: database system is ready to accept connections ``` start cmd /c ".\tools\bin\pg_ctl.exe -D .\data\ -l .\start-log-outside.log stop" ``` 2022-11-10 12:58:47.779 GMT [48928] LOG: received fast shutdown request 2022-11-10 12:58:47.791 GMT [48928] LOG: aborting any active transactions 2022-11-10 12:58:47.798 GMT [48928] LOG: background worker "logical replication launcher" (PID 27328) exited with exit code 1 2022-11-10 12:58:47.799 GMT [14988] LOG: shutting down 2022-11-10 12:58:47.800 GMT [14988] LOG: checkpoint starting: shutdown immediate 2022-11-10 12:58:47.807 GMT [14988] LOG: checkpoint complete: wrote 0 buffers (0.0%); 0 WAL file(s) added, 0 removed, 0 recycled; write=0.001 s, sync=0.001 s, total=0.009 s; sync files=0, longest=0.000 s, average=0.000 s; distance=0 kB, estimate=0 kB 2022-11-10 12:58:47.814 GMT [48928] LOG: database system is shut down ``` cmd /c ".\tools\bin\pg_ctl.exe -D .\data\ -l .\start-log-outside.log start" ``` 2022-11-10 13:04:40.239 GMT [49696] LOG: starting PostgreSQL 15.0, compiled by Visual C++ build 1914, 64-bit 2022-11-10 13:04:40.245 GMT [49696] LOG: listening on IPv6 address "::1", port 5432 2022-11-10 13:04:40.245 GMT [49696] LOG: listening on IPv4 address "127.0.0.1", port 5432 2022-11-10 13:04:40.315 GMT [17204] LOG: database system was interrupted; last known up at 2022-11-10 13:00:13 GMT 2022-11-10 13:04:40.869 GMT [17204] LOG: database system was not properly shut down; automatic recovery in progress 2022-11-10 13:04:40.875 GMT [17204] LOG: invalid record length at 0/A438530: wanted 24, got 0 2022-11-10 13:04:40.875 GMT [17204] LOG: redo is not required 2022-11-10 13:04:40.887 GMT [40444] LOG: checkpoint starting: end-of-recovery immediate wait 2022-11-10 13:04:40.895 GMT [40444] LOG: checkpoint complete: wrote 3 buffers (0.0%); 0 WAL file(s) added, 0 removed, 0 recycled; write=0.002 s, sync=0.002 s, total=0.013 s; sync files=2, longest=0.001 s, average=0.001 s; distance=0 kB, estimate=0 kB 2022-11-10 13:04:40.909 GMT [49696] LOG: database system is ready to accept connections ``` cmd /c ".\tools\bin\pg_ctl.exe -D .\data\ -l .\start-log-outside.log stop" ``` 2022-11-10 13:04:50.341 GMT [49696] LOG: received fast shutdown request 2022-11-10 13:04:50.363 GMT [49696] LOG: aborting any active transactions 2022-11-10 13:04:50.368 GMT [49696] LOG: background worker "logical replication launcher" (PID 48012) exited with exit code 1 2022-11-10 13:04:50.368 GMT [40444] LOG: shutting down 2022-11-10 13:04:50.369 GMT [40444] LOG: checkpoint starting: shutdown immediate 2022-11-10 13:04:50.375 GMT [40444] LOG: checkpoint complete: wrote 0 buffers (0.0%); 0 WAL file(s) added, 0 removed, 0 recycled; write=0.001 s, sync=0.001 s, total=0.008 s; sync files=0, longest=0.000 s, average=0.000 s; distance=0 kB, estimate=0 kB 2022-11-10 13:04:50.380 GMT [49696] LOG: database system is shut down ### Expected Behavior Starting pg_ctl on a new terminal window should work and postgres should stay up Starting pg_ctl on the current terminal should work and postgres should stay up ### Actual Behavior Starting pg_ctl on a new terminal window causes postgres to fail to start Starting pg_ctl on the current terminal window works.
Author
Owner

@brunomlopes commented on GitHub (Mar 13, 2023):

bump ?

As someone who uses postgresql daily, this is blocking our usage of the windows terminal, and leaves us with the old prompt as the default.

Is there more info I can provide?

@brunomlopes commented on GitHub (Mar 13, 2023): *bump* ? As someone who uses postgresql daily, this is blocking our usage of the windows terminal, and leaves us with the old prompt as the default. Is there more info I can provide?
Author
Owner

@lhecker commented on GitHub (Mar 16, 2023):

I've re-tested this today and found that this got fixed by #14544 as well. So far it's only been released in Windows Terminal Preview v1.17. After installing it from the store or from GitHub's releases, you can manually set it as your default terminal in the settings:
image

@lhecker commented on GitHub (Mar 16, 2023): I've re-tested this today and found that this got fixed by #14544 as well. So far it's only been released in Windows Terminal Preview v1.17. After installing it from the store or from GitHub's releases, you can manually set it as your default terminal in the settings: ![image](https://user-images.githubusercontent.com/2256941/225759978-0cfa3c46-58ce-48b4-84be-fe7dcde2c89b.png)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#18860