Re: BUG #14287: psql_history gets wiped out

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Rick Otten <rotten(at)windfish(dot)net>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #14287: psql_history gets wiped out
Date: 2016-08-12 14:50:01
Message-ID: 27413.1471013401@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Rick Otten <rotten(at)windfish(dot)net> writes:
> And here is what the last few lines of the strace look like when I close
> the (ssh terminal) window:

> --- SIGHUP {si_signo=SIGHUP, si_code=SI_USER, si_pid=95075, si_uid=5432}
> ---
> +++ killed by SIGHUP +++

So the issue seems to be that psql is getting killed by SIGHUP before
it can write the history file (in this example), or in the midst of
writing the history file (in your problem cases), depending on timing.

The weird thing here is that psql is able to see EOF on stdin and
begin taking actions in response to that before SIGHUP arrives.
I'm not sure if that's expected or not. That seems like a deliberately
created race condition, which is seldom a good idea.

Anyway it seems like your behavioral change must boil down to a timing
change in either the kernel or sshd. There's nothing in psql that changed
in this area, and probably not in libedit either.

We could maybe try to prevent this by blocking signals while writing the
history file, but I'm not exactly convinced that would be a good idea.
It's probably be better to pester kernel & sshd people about whether
they changed anything here.

regards, tom lane

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Rick Otten 2016-08-12 15:13:58 Re: BUG #14287: psql_history gets wiped out
Previous Message Rick Otten 2016-08-12 14:17:04 Re: BUG #14287: psql_history gets wiped out