Test 030_pager.pl might fail due to race on set_winsize
От:
Alexander Lakhin <exclusion@gmail.com>
Дата:
Вложения:
Hello hackers,
Let me present you the first failure of 030_pager.pl (committed on
2025-10-07) produced by scorpion a week ago [1]:
404/404 psql - postgresql:psql/030_pager ERROR 182.25s exit status 29
[00:46:29.628](0.815s) # connect output:
# {
# 'stderr' => 'background_psql: ready
# ',
# 'stdout' => '\\\\echo \\'background_psql: ready\\'
# \\\\warn \\'background_psql: ready\\'
# psql (20devel)
# Type "help" for help.
#
# postgres=# \\\\echo \\'background_psql: ready\\'
# background_psql: ready
# postgres=# \\\\warn \\'background_psql: ready\\'
# '
# }
[00:49:30.263](180.635s) # die: IPC::Run: timeout on timer #1 at /usr/share/perl5/IPC/Run.pm line 3361.
[00:49:30.264](0.000s) 1..0
IPC::Run: timeout on timer #1 at /usr/share/perl5/IPC/Run.pm line 3361.
Compare with the next (successful) run [2]:
[02:14:07.553](0.552s) # connect output:
# {
# 'stderr' => 'background_psql: ready
# ',
# 'stdout' => '\\\\echo \\'background_psql: ready\\'
# \\\\warn \\'background_psql: ready\\'
# psql (20devel)
# Type "help" for help.
#
# postgres=# \\\\echo \\'background_psql: ready\\'
# background_psql: ready
# postgres=# \\\\warn \\'background_psql: ready\\'
# postgres=# '
# }
[02:14:07.587](0.033s) ok 1 - execute SELECT query that needs no pagination
In the failed run, "connect output" doesn't end with "postgres=#".
I've reproduced this locally, with multiple 030 tests running in parallel,
and the debug logging added after:
@@ -3125,6 +3125,14 @@ PageOutputInternal(int lines, const printTableOpt *topt,
struct winsize screen_size;
result = ioctl(fileno(stdout), TIOCGWINSZ, &screen_size);
showed:
!!!PageOutputInternal| result: 0, screen_size.ws_row: 0, screen_size.ws_col: 0
With 030_pager.pl simplified to the attached and multiplied x40, the
following test run:
meson test psql_*/030_pager -j 10
reproduces the issue pretty reliably for me:
Ok: 36
Fail: 4
[14:06:57.115](0.005s) # connect output:
# {
# 'stderr' => 'background_psql: ready
# ',
# 'stdout' => '\\echo \'background_psql: ready\'^M
# \\warn \'background_psql: ready\'^M
# psql (20devel)^M
# Type "help" for help.^M
# ^M
# postgres=# \\echo \'background_psql: ready\'^M
# background_psql: ready^M
# postgres=# \\warn \'background_psql: ready\'^M
# postgres=# '
# }
[14:06:57.123](0.008s) # psql PTY check output:
# ^M 'background_psql: ready
# ',
# 'stdout' => '\\echo \'background_psql: ready\'^M
# \\warn \'background_psql: ready\'^M
# psql (20devel)^M
# Type "help" for help.^M
# ^M
# postgres=# \\echo \'background_psql: ready\'^M
# background_psql: ready^M
# postgres=# \\warn \'background_psql: ready\'^M
# '
# }
[14:06:57.136](0.007s) # psql PTY check output:
# \! python3 -c "import fcntl,termios,struct; r,c,hp,wp=struct.unpack('HHHH', fcntl.ioctl(1, termios.TIOCGWINSZ,
bytes(8))); print(f'ioctl1 rows={r} cols={c}')"^M
# \echo 'PTYCHECK_DONE'^M
# postgres=# ^M