Re: psql tests hangs - Mailing list pgsql-hackers

From Kirk Wolak
Subject Re: psql tests hangs
Date
Msg-id CACLU5mQx+Zf09V4-wYaTOX=6oQ7GMY1KTmiqKdijkVt-wtXwow@mail.gmail.com
Whole thread Raw
In response to Re: psql tests hangs  (Pavel Stehule <pavel.stehule@gmail.com>)
List pgsql-hackers
On Fri, May 12, 2023 at 2:40 AM Pavel Stehule <pavel.stehule@gmail.com> wrote:
pá 12. 5. 2023 v 8:20 odesílatel Kirk Wolak <wolakk@gmail.com> napsal:
On Fri, May 12, 2023 at 1:46 AM Pavel Stehule <pavel.stehule@gmail.com> wrote:
pá 12. 5. 2023 v 6:50 odesílatel Kirk Wolak <wolakk@gmail.com> napsal:
On Fri, May 12, 2023 at 12:14 AM Tom Lane <tgl@sss.pgh.pa.us> wrote:
Kirk Wolak <wolakk@gmail.com> writes:
> Did you try the print statement that Andrey asked Pavel to try?
...

The strange thing is hanging. Broken tests depending on locale are usual. But I didn't remember hanging.

Regards

Pavel

So, if you do psql -c "..."
with both of those \watch  instructions, do either one hang? (I am now guessing "no")

I know that perl is using a special library to "remote control psql" (like a pseudo terminal, I guess).
[I had to abort some of the perl testing in Windows because that perl library didn't work with my psql in Windows]

Next, can you detect which process is hanging? (is it perl, the library, psql, ?).

It hangs in perl

but now I found there is dependency on PSQL_PAGER setting

it started pager in background, I had lot of zombie pspg processes

Unfortunately, when I unset this variable, the test hangs still

here is backtrace

Missing separate debuginfos, use: dnf debuginfo-install perl-interpreter-5.36.1-496.fc38.x86_64
(gdb) bt
#0  0x00007fbbc1129ade in select () from /lib64/libc.so.6
#1  0x00007fbbc137363b in Perl_pp_sselect () from /lib64/libperl.so.5.36
#2  0x00007fbbc1317958 in Perl_runops_standard () from /lib64/libperl.so.5.36
#3  0x00007fbbc128259d in perl_run () from /lib64/libperl.so.5.36
#4  0x000056392bd9034a in main ()

It is waiting on reading from pipe probably

psql is living too, and it is waiting too

Using host libthread_db library "/lib64/libthread_db.so.1".
0x00007f071740bc37 in wait4 () from /lib64/libc.so.6
Missing separate debuginfos, use: dnf debuginfo-install glibc-2.37-4.fc38.x86_64 ncurses-libs-6.4-3.20230114.fc38.x86_64 readline-8.2-3.fc38.x86_64
(gdb) bt
#0  0x00007f071740bc37 in wait4 () from /lib64/libc.so.6
#1  0x00007f07173a9a10 in _IO_proc_close@@GLIBC_2.2.5 () from /lib64/libc.so.6
#2  0x00007f07173b51e9 in __GI__IO_file_close_it () from /lib64/libc.so.6
#3  0x00007f07173a79fb in fclose@@GLIBC_2.2.5 () from /lib64/libc.so.6
#4  0x0000000000406be4 in do_watch (query_buf=query_buf@entry=0x5ae540, sleep=sleep@entry=0.01, iter=0, iter@entry=3) at command.c:5348
#5  0x00000000004087a5 in exec_command_watch (scan_state=scan_state@entry=0x5ae490, active_branch=active_branch@entry=true, query_buf=query_buf@entry=0x5ae540, previous_buf=previous_buf@entry=0x5ae560) at command.c:2875
#6  0x000000000040d4ba in exec_command (previous_buf=0x5ae560, query_buf=0x5ae540, cstack=0x5ae520, scan_state=0x5ae490, cmd=0x5ae9a0 "watch") at command.c:413
#7  HandleSlashCmds (scan_state=scan_state@entry=0x5ae490, cstack=cstack@entry=0x5ae520, query_buf=0x5ae540, previous_buf=0x5ae560) at command.c:230

I am not sure, it is still doesn't work but probably there are some dependencies on my setting

PSQL_PAGER and PSQL_WATCH_PAGER

so this tests fails due my setting

[pavel@localhost postgresql.master]$ set |grep PSQL
PSQL_PAGER='pspg -X'
PSQL_WATCH_PAGER='pspg -X --stream'

Regards

Pavel


Ummm... We are testing PSQL \watch  and you potentially have a PSQL_WATCH_PAGER that is kicking in?
By chance does that attempt to read/process/understand the \watch ?
Also, if it is interfering with the stream, that would explain it.  The perl library is trying to "control" psql.
If it ends up talking to you instead... All bets are off, imo.  I don't know enough about PSQL_WATCH_PAGER.

Now I would be curious if you changed the test from
SELECT 1 \watch c=3 0.01 

to 
SELECT 1 \watch 0.01

because that should work.  Then I would test
SELECT \watch 0.01 c=3

If you are trying to parse the watch at all, that could break.  Then your code might be trying to "complain",
and then that is screwing up the planned interaction (Just Guessing).

Kirk...

pgsql-hackers by date:

Previous
From: Pavel Stehule
Date:
Subject: Re: psql tests hangs
Next
From: Richard Guo
Date:
Subject: Re: Assert failure of the cross-check for nullingrels