Skip to content

Unsupported Windows command line options - #620

Merged
eulerto merged 2 commits into
pgbouncer:masterfrom
eulerto:unsupported-win-cmdline-options
Jan 18, 2023
Merged

Unsupported Windows command line options#620
eulerto merged 2 commits into
pgbouncer:masterfrom
eulerto:unsupported-win-cmdline-options

Conversation

@eulerto

@eulerto eulerto commented Jun 27, 2021

Copy link
Copy Markdown
Member

Provide suitable FATAL messages for unsupported options on Windows.

@petere

petere commented Jul 9, 2021

Copy link
Copy Markdown
Member

We used to have something similar already, but it was removed by afa978f. That commit message said "Unsupported system calls will error appropriately.". Does that not work sufficiently?

@eulerto

eulerto commented Jul 9, 2021

Copy link
Copy Markdown
Member Author

No. See the current behavior. Option -R provides a FATAL message but the routine is not correct. Option -u provides a FATAL message but the OS user exists so the message is not correct too. Option -d doesn't even provide a FATAL message and terminates without a suitable message.

C:\>c:\temp\pgbouncer\bin\pgbouncer.exe -v -R c:\temp\pgbouncer\etc\pgbouncer.ini
2021-07-09 10:07:12.494 UTC [8548] DEBUG parse_ini_file: [databases]
2021-07-09 10:07:12.501 UTC [8548] DEBUG parse_ini_file: [users]
2021-07-09 10:07:12.503 UTC [8548] DEBUG parse_ini_file: [pgbouncer]
2021-07-09 10:07:12.505 UTC [8548] DEBUG parse_ini_file: 'logfile' = 'C:\temp\pgbouncer\log\pgbouncer.log'
2021-07-09 10:07:12.507 UTC [8548] DEBUG parse_ini_file: 'logfile' = 'C:\temp\pgbouncer\log\pgbouncer.log' ok:1
2021-07-09 10:07:12.511 UTC [8548] DEBUG parse_ini_file: 'pidfile' = 'C:\temp\pgbouncer\run\pgbouncer.pid'
2021-07-09 10:07:12.515 UTC [8548] DEBUG parse_ini_file: 'pidfile' = 'C:\temp\pgbouncer\run\pgbouncer.pid' ok:1
2021-07-09 10:07:12.518 UTC [8548] DEBUG parse_ini_file: 'listen_addr' = 'localhost'
2021-07-09 10:07:12.522 UTC [8548] DEBUG parse_ini_file: 'listen_addr' = 'localhost' ok:1
2021-07-09 10:07:12.525 UTC [8548] DEBUG parse_ini_file: 'listen_port' = '6432'
2021-07-09 10:07:12.527 UTC [8548] DEBUG parse_ini_file: 'listen_port' = '6432' ok:1
2021-07-09 10:07:12.530 UTC [8548] DEBUG parse_ini_file: 'auth_type' = 'trust'
2021-07-09 10:07:12.532 UTC [8548] DEBUG parse_ini_file: 'auth_type' = 'trust' ok:1
2021-07-09 10:07:12.534 UTC [8548] DEBUG parse_ini_file: 'auth_file' = 'C:\temp\pgbouncer\etc\userlist.txt'
2021-07-09 10:07:12.538 UTC [8548] DEBUG parse_ini_file: 'auth_file' = 'C:\temp\pgbouncer\etc\userlist.txt' ok:1
2021-07-09 10:07:12.543 UTC [8548] DEBUG loading auth_file: "C:\temp\pgbouncer\etc\userlist.txt"
2021-07-09 10:07:12.549 UTC [8548] DEBUG pktbuf_dynamic(128): 0000025a10c33c20
2021-07-09 10:07:12.552 UTC [8548] DEBUG make_room(0000025a10c33c20, 9): realloc newlen=256
2021-07-09 10:07:12.555 UTC [8548] DEBUG pktbuf_dynamic(128): 0000025a10c33df0
2021-07-09 10:07:12.557 UTC [8548] LOG old process not found, try to continue normally
2021-07-09 10:07:12.561 UTC [8548] FATAL pidfile exists, another instance running?


C:\>c:\temp\pgbouncer\bin\pgbouncer.exe -v -u euler c:\temp\pgbouncer\etc\pgbouncer.ini
2021-07-09 10:18:49.416 UTC [8776] DEBUG parse_ini_file: [databases]
2021-07-09 10:18:49.424 UTC [8776] DEBUG parse_ini_file: [users]
2021-07-09 10:18:49.426 UTC [8776] DEBUG parse_ini_file: [pgbouncer]
2021-07-09 10:18:49.428 UTC [8776] DEBUG parse_ini_file: 'logfile' = 'C:\temp\pgbouncer\log\pgbouncer.log'
2021-07-09 10:18:49.432 UTC [8776] DEBUG parse_ini_file: 'logfile' = 'C:\temp\pgbouncer\log\pgbouncer.log' ok:1
2021-07-09 10:18:49.437 UTC [8776] DEBUG parse_ini_file: 'pidfile' = 'C:\temp\pgbouncer\run\pgbouncer.pid'
2021-07-09 10:18:49.445 UTC [8776] DEBUG parse_ini_file: 'pidfile' = 'C:\temp\pgbouncer\run\pgbouncer.pid' ok:1
2021-07-09 10:18:49.449 UTC [8776] DEBUG parse_ini_file: 'listen_addr' = 'localhost'
2021-07-09 10:18:49.452 UTC [8776] DEBUG parse_ini_file: 'listen_addr' = 'localhost' ok:1
2021-07-09 10:18:49.456 UTC [8776] DEBUG parse_ini_file: 'listen_port' = '6432'
2021-07-09 10:18:49.459 UTC [8776] DEBUG parse_ini_file: 'listen_port' = '6432' ok:1
2021-07-09 10:18:49.462 UTC [8776] DEBUG parse_ini_file: 'auth_type' = 'trust'
2021-07-09 10:18:49.465 UTC [8776] DEBUG parse_ini_file: 'auth_type' = 'trust' ok:1
2021-07-09 10:18:49.468 UTC [8776] DEBUG parse_ini_file: 'auth_file' = 'C:\temp\pgbouncer\etc\userlist.txt'
2021-07-09 10:18:49.472 UTC [8776] DEBUG parse_ini_file: 'auth_file' = 'C:\temp\pgbouncer\etc\userlist.txt' ok:1
2021-07-09 10:18:49.478 UTC [8776] DEBUG loading auth_file: "C:\temp\pgbouncer\etc\userlist.txt"
2021-07-09 10:18:49.487 UTC [8776] FATAL could not find user 'euler' to switch to


C:\>c:\temp\pgbouncer\bin\pgbouncer.exe -v -d c:\temp\pgbouncer\etc\pgbouncer.ini
2021-07-09 10:19:14.611 UTC [2692] DEBUG parse_ini_file: [databases]
2021-07-09 10:19:14.618 UTC [2692] DEBUG parse_ini_file: [users]
2021-07-09 10:19:14.620 UTC [2692] DEBUG parse_ini_file: [pgbouncer]
2021-07-09 10:19:14.623 UTC [2692] DEBUG parse_ini_file: 'logfile' = 'C:\temp\pgbouncer\log\pgbouncer.log'
2021-07-09 10:19:14.626 UTC [2692] DEBUG parse_ini_file: 'logfile' = 'C:\temp\pgbouncer\log\pgbouncer.log' ok:1
2021-07-09 10:19:14.630 UTC [2692] DEBUG parse_ini_file: 'pidfile' = 'C:\temp\pgbouncer\run\pgbouncer.pid'
2021-07-09 10:19:14.634 UTC [2692] DEBUG parse_ini_file: 'pidfile' = 'C:\temp\pgbouncer\run\pgbouncer.pid' ok:1
2021-07-09 10:19:14.638 UTC [2692] DEBUG parse_ini_file: 'listen_addr' = 'localhost'
2021-07-09 10:19:14.643 UTC [2692] DEBUG parse_ini_file: 'listen_addr' = 'localhost' ok:1
2021-07-09 10:19:14.646 UTC [2692] DEBUG parse_ini_file: 'listen_port' = '6432'
2021-07-09 10:19:14.648 UTC [2692] DEBUG parse_ini_file: 'listen_port' = '6432' ok:1
2021-07-09 10:19:14.652 UTC [2692] DEBUG parse_ini_file: 'auth_type' = 'trust'
2021-07-09 10:19:14.654 UTC [2692] DEBUG parse_ini_file: 'auth_type' = 'trust' ok:1
2021-07-09 10:19:14.657 UTC [2692] DEBUG parse_ini_file: 'auth_file' = 'C:\temp\pgbouncer\etc\userlist.txt'
2021-07-09 10:19:14.661 UTC [2692] DEBUG parse_ini_file: 'auth_file' = 'C:\temp\pgbouncer\etc\userlist.txt' ok:1
2021-07-09 10:19:14.665 UTC [2692] DEBUG loading auth_file: "C:\temp\pgbouncer\etc\userlist.txt"
2021-07-09 10:19:14.674 UTC [2692] DEBUG pktbuf_dynamic(128): 000001f90f2670c0
2021-07-09 10:19:14.677 UTC [2692] DEBUG make_room(000001f90f2670c0, 9): realloc newlen=256
2021-07-09 10:19:14.680 UTC [2692] DEBUG pktbuf_dynamic(128): 000001f90f263d70

@petere

petere commented Jul 14, 2021

Copy link
Copy Markdown
Member

No. See the current behavior. Option -R provides a FATAL message but the routine is not correct. Option -u provides a FATAL message but the OS user exists so the message is not correct too. Option -d doesn't even provide a FATAL message and terminates without a suitable message.

C:\>c:\temp\pgbouncer\bin\pgbouncer.exe -v -R c:\temp\pgbouncer\etc\pgbouncer.ini
2021-07-09 10:07:12.494 UTC [8548] DEBUG parse_ini_file: [databases]
2021-07-09 10:07:12.501 UTC [8548] DEBUG parse_ini_file: [users]
2021-07-09 10:07:12.503 UTC [8548] DEBUG parse_ini_file: [pgbouncer]
2021-07-09 10:07:12.505 UTC [8548] DEBUG parse_ini_file: 'logfile' = 'C:\temp\pgbouncer\log\pgbouncer.log'
2021-07-09 10:07:12.507 UTC [8548] DEBUG parse_ini_file: 'logfile' = 'C:\temp\pgbouncer\log\pgbouncer.log' ok:1
2021-07-09 10:07:12.511 UTC [8548] DEBUG parse_ini_file: 'pidfile' = 'C:\temp\pgbouncer\run\pgbouncer.pid'
2021-07-09 10:07:12.515 UTC [8548] DEBUG parse_ini_file: 'pidfile' = 'C:\temp\pgbouncer\run\pgbouncer.pid' ok:1
2021-07-09 10:07:12.518 UTC [8548] DEBUG parse_ini_file: 'listen_addr' = 'localhost'
2021-07-09 10:07:12.522 UTC [8548] DEBUG parse_ini_file: 'listen_addr' = 'localhost' ok:1
2021-07-09 10:07:12.525 UTC [8548] DEBUG parse_ini_file: 'listen_port' = '6432'
2021-07-09 10:07:12.527 UTC [8548] DEBUG parse_ini_file: 'listen_port' = '6432' ok:1
2021-07-09 10:07:12.530 UTC [8548] DEBUG parse_ini_file: 'auth_type' = 'trust'
2021-07-09 10:07:12.532 UTC [8548] DEBUG parse_ini_file: 'auth_type' = 'trust' ok:1
2021-07-09 10:07:12.534 UTC [8548] DEBUG parse_ini_file: 'auth_file' = 'C:\temp\pgbouncer\etc\userlist.txt'
2021-07-09 10:07:12.538 UTC [8548] DEBUG parse_ini_file: 'auth_file' = 'C:\temp\pgbouncer\etc\userlist.txt' ok:1
2021-07-09 10:07:12.543 UTC [8548] DEBUG loading auth_file: "C:\temp\pgbouncer\etc\userlist.txt"
2021-07-09 10:07:12.549 UTC [8548] DEBUG pktbuf_dynamic(128): 0000025a10c33c20
2021-07-09 10:07:12.552 UTC [8548] DEBUG make_room(0000025a10c33c20, 9): realloc newlen=256
2021-07-09 10:07:12.555 UTC [8548] DEBUG pktbuf_dynamic(128): 0000025a10c33df0
2021-07-09 10:07:12.557 UTC [8548] LOG old process not found, try to continue normally
2021-07-09 10:07:12.561 UTC [8548] FATAL pidfile exists, another instance running?

This is from check_pidfile(), which is also run in the non--R case, so I'm confused by how this happens. Maybe there actually was another instance running in this test scenario?

C:>c:\temp\pgbouncer\bin\pgbouncer.exe -v -u euler c:\temp\pgbouncer\etc\pgbouncer.ini
2021-07-09 10:18:49.416 UTC [8776] DEBUG parse_ini_file: [databases]
2021-07-09 10:18:49.424 UTC [8776] DEBUG parse_ini_file: [users]
2021-07-09 10:18:49.426 UTC [8776] DEBUG parse_ini_file: [pgbouncer]
2021-07-09 10:18:49.428 UTC [8776] DEBUG parse_ini_file: 'logfile' = 'C:\temp\pgbouncer\log\pgbouncer.log'
2021-07-09 10:18:49.432 UTC [8776] DEBUG parse_ini_file: 'logfile' = 'C:\temp\pgbouncer\log\pgbouncer.log' ok:1
2021-07-09 10:18:49.437 UTC [8776] DEBUG parse_ini_file: 'pidfile' = 'C:\temp\pgbouncer\run\pgbouncer.pid'
2021-07-09 10:18:49.445 UTC [8776] DEBUG parse_ini_file: 'pidfile' = 'C:\temp\pgbouncer\run\pgbouncer.pid' ok:1
2021-07-09 10:18:49.449 UTC [8776] DEBUG parse_ini_file: 'listen_addr' = 'localhost'
2021-07-09 10:18:49.452 UTC [8776] DEBUG parse_ini_file: 'listen_addr' = 'localhost' ok:1
2021-07-09 10:18:49.456 UTC [8776] DEBUG parse_ini_file: 'listen_port' = '6432'
2021-07-09 10:18:49.459 UTC [8776] DEBUG parse_ini_file: 'listen_port' = '6432' ok:1
2021-07-09 10:18:49.462 UTC [8776] DEBUG parse_ini_file: 'auth_type' = 'trust'
2021-07-09 10:18:49.465 UTC [8776] DEBUG parse_ini_file: 'auth_type' = 'trust' ok:1
2021-07-09 10:18:49.468 UTC [8776] DEBUG parse_ini_file: 'auth_file' = 'C:\temp\pgbouncer\etc\userlist.txt'
2021-07-09 10:18:49.472 UTC [8776] DEBUG parse_ini_file: 'auth_file' = 'C:\temp\pgbouncer\etc\userlist.txt' ok:1
2021-07-09 10:18:49.478 UTC [8776] DEBUG loading auth_file: "C:\temp\pgbouncer\etc\userlist.txt"
2021-07-09 10:18:49.487 UTC [8776] FATAL could not find user 'euler' to switch to

Okay, this could be improved.

C:>c:\temp\pgbouncer\bin\pgbouncer.exe -v -d c:\temp\pgbouncer\etc\pgbouncer.ini
2021-07-09 10:19:14.611 UTC [2692] DEBUG parse_ini_file: [databases]
2021-07-09 10:19:14.618 UTC [2692] DEBUG parse_ini_file: [users]
2021-07-09 10:19:14.620 UTC [2692] DEBUG parse_ini_file: [pgbouncer]
2021-07-09 10:19:14.623 UTC [2692] DEBUG parse_ini_file: 'logfile' = 'C:\temp\pgbouncer\log\pgbouncer.log'
2021-07-09 10:19:14.626 UTC [2692] DEBUG parse_ini_file: 'logfile' = 'C:\temp\pgbouncer\log\pgbouncer.log' ok:1
2021-07-09 10:19:14.630 UTC [2692] DEBUG parse_ini_file: 'pidfile' = 'C:\temp\pgbouncer\run\pgbouncer.pid'
2021-07-09 10:19:14.634 UTC [2692] DEBUG parse_ini_file: 'pidfile' = 'C:\temp\pgbouncer\run\pgbouncer.pid' ok:1
2021-07-09 10:19:14.638 UTC [2692] DEBUG parse_ini_file: 'listen_addr' = 'localhost'
2021-07-09 10:19:14.643 UTC [2692] DEBUG parse_ini_file: 'listen_addr' = 'localhost' ok:1
2021-07-09 10:19:14.646 UTC [2692] DEBUG parse_ini_file: 'listen_port' = '6432'
2021-07-09 10:19:14.648 UTC [2692] DEBUG parse_ini_file: 'listen_port' = '6432' ok:1
2021-07-09 10:19:14.652 UTC [2692] DEBUG parse_ini_file: 'auth_type' = 'trust'
2021-07-09 10:19:14.654 UTC [2692] DEBUG parse_ini_file: 'auth_type' = 'trust' ok:1
2021-07-09 10:19:14.657 UTC [2692] DEBUG parse_ini_file: 'auth_file' = 'C:\temp\pgbouncer\etc\userlist.txt'
2021-07-09 10:19:14.661 UTC [2692] DEBUG parse_ini_file: 'auth_file' = 'C:\temp\pgbouncer\etc\userlist.txt' ok:1
2021-07-09 10:19:14.665 UTC [2692] DEBUG loading auth_file: "C:\temp\pgbouncer\etc\userlist.txt"
2021-07-09 10:19:14.674 UTC [2692] DEBUG pktbuf_dynamic(128): 000001f90f2670c0
2021-07-09 10:19:14.677 UTC [2692] DEBUG make_room(000001f90f2670c0, 9): realloc newlen=256
2021-07-09 10:19:14.680 UTC [2692] DEBUG pktbuf_dynamic(128): 000001f90f263d70

This is weird. I would expect that it would fail at the fork() call in go_daemon(). Can you check where it fails, maybe by inserting some debug messages?

@eulerto

eulerto commented Jan 11, 2023

Copy link
Copy Markdown
Member Author

I'm back to this issue.

This is from check_pidfile(), which is also run in the non--R case, so I'm confused by how this happens. Maybe there actually was another instance running in this test scenario?

pgbouncer/src/main.c

Lines 965 to 978 in cffa192

if (cf_reboot) {
if (check_old_process_unix()) {
takeover_part1();
did_takeover = true;
} else {
log_info("old process not found, try to continue normally");
cf_reboot = 0;
check_pidfile();
}
} else {
if (check_old_process_unix())
die("unix socket is in use, cannot continue");
check_pidfile();
}

check_old_process_unix function returns false because I haven't setup the socket directory. Hence, it ran check_pidfile function. If I set it up, connect() fails with No connection could be made because the target machine actively refused it. I also tried an abstract Unix-domain sockets but it fails too (An invalid argument was supplied). I didn't pursue it further. Once we fix this portability issue, this error message can be removed.

This is weird. I would expect that it would fail at the fork() call in go_daemon(). Can you check where it fails, maybe by inserting some debug messages?

Ooops. I didn't provide the whole log. (Those messages were from the terminal.) Log contains

2023-01-10 18:46:18.827 UTC [35132] DEBUG pktbuf_dynamic(128): 0000017608b0e0f0
2023-01-10 18:46:18.830 UTC [35132] FATAL could not open /dev/null: The system cannot find the file specified.
2023-01-10 18:46:18.831 UTC [35132] WARNING dropping database 'pgbouncer' as it does not exist anymore or inactive auto-database
2023-01-10 18:46:18.831 UTC [35132] DEBUG pktbuf_free(000001760a44ff50)
2023-01-10 18:46:18.832 UTC [35132] DEBUG pktbuf_free(0000017608b0e0f0)

When I replace /dev/null with nul it fails in fork().

Do you agree applying these error messages for usability purposes?

@petere

petere commented Jan 12, 2023

Copy link
Copy Markdown
Member

Do you agree applying these error messages for usability purposes?

For -d and -u okay, but the lack of support for -R is not specific to Windows, so handling that specially doesn't seem appropriate.

Option --user is not supported on Windows. Despite of having a FATAL
message, it is not accurate. Let's provide the real cause of why the
service did not start.
Option --daemon is not supported on Windows. Despite of having a FATAL
message, it is not accurate. Let's provide the real cause of why the
service did not start.
@eulerto
eulerto force-pushed the unsupported-win-cmdline-options branch from 7f89309 to 4bc1ffe Compare January 16, 2023 14:22
@eulerto
eulerto merged commit dfe2c98 into pgbouncer:master Jan 18, 2023
@eulerto
eulerto deleted the unsupported-win-cmdline-options branch November 8, 2023 18:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants