pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
BUG #15076: postmaster crashes unexpectedly when using up arrow key in psql command
12+ messages / 6 participants
[nested] [flat]

* BUG #15076: postmaster crashes unexpectedly when using up arrow key in psql command
@ 2018-02-22 01:15 PG Bug reporting form <noreply@postgresql.org>
  2018-02-22 03:29 ` Re: BUG #15076: postmaster crashes unexpectedly when using up arrow key in psql command David G. Johnston <david.g.johnston@gmail.com>
  0 siblings, 1 reply; 12+ messages in thread

From: PG Bug reporting form @ 2018-02-22 01:15 UTC (permalink / raw)
  To: pgsql-bugs@lists.postgresql.org; +Cc: mzhao@insight-tec.co.jp

The following bug has been logged on the website:

Bug reference:      15076
Logged by:          Mingchun Zhao
Email address:      mzhao@insight-tec.co.jp
PostgreSQL version: 9.3.20
Operating system:   Windows
Description:        

steps to reproduce:

(1) run psql.exe in a Windows Command Prompt
(2) execute a SQL with more than one page of results, e.g. `show all;`
(3) press Ctrl + C to break it on the first page
(4) press up arrow key to try to execute the previous SQL of the step(2)
again
(5) Occasionally, it will show you nothing about the SQL, then you can try
to input a character ';' and press Enter key, the PostgreSQL will crash
unexpectedly




^ permalink  raw  reply  [nested|flat] 12+ messages in thread

* Re: BUG #15076: postmaster crashes unexpectedly when using up arrow key in psql command
  2018-02-22 01:15 BUG #15076: postmaster crashes unexpectedly when using up arrow key in psql command PG Bug reporting form <noreply@postgresql.org>
@ 2018-02-22 03:29 ` David G. Johnston <david.g.johnston@gmail.com>
  2018-02-22 04:06   ` Re: BUG #15076: postmaster crashes unexpectedly when using up arrow key in psql command Tom Lane <tgl@sss.pgh.pa.us>
  2018-02-22 06:45   ` Re: BUG #15076: postmaster crashes unexpectedly when using up arrow key in psql command 趙明春 <mzhao@insight-tec.co.jp>
  0 siblings, 2 replies; 12+ messages in thread

From: David G. Johnston @ 2018-02-22 03:29 UTC (permalink / raw)
  To: mzhao@insight-tec.co.jp <mzhao@insight-tec.co.jp>; pgsql-bugs@lists.postgresql.org <pgsql-bugs@lists.postgresql.org>

On Wednesday, February 21, 2018, PG Bug reporting form <
noreply@postgresql.org> wrote:

> The following bug has been logged on the website:
>
> Bug reference:      15076
> Logged by:          Mingchun Zhao
> Email address:      mzhao@insight-tec.co.jp
> PostgreSQL version: 9.3.20
> Operating system:   Windows
> Description:
>
> steps to reproduce:
>
> (1) run psql.exe in a Windows Command Prompt
> (2) execute a SQL with more than one page of results, e.g. `show all;`
> (3) press Ctrl + C to break it on the first page
> (4) press up arrow key to try to execute the previous SQL of the step(2)
> again
> (5) Occasionally, it will show you nothing about the SQL, then you can try
> to input a character ';' and press Enter key, the PostgreSQL will crash
> unexpectedly
>
>
It would help to explain what you actually see in step 5 instead of just
saying crash.  In particular is the "failure" in the server or client?

David J.

^ permalink  raw  reply  [nested|flat] 12+ messages in thread

* Re: BUG #15076: postmaster crashes unexpectedly when using up arrow key in psql command
  2018-02-22 01:15 BUG #15076: postmaster crashes unexpectedly when using up arrow key in psql command PG Bug reporting form <noreply@postgresql.org>
  2018-02-22 03:29 ` Re: BUG #15076: postmaster crashes unexpectedly when using up arrow key in psql command David G. Johnston <david.g.johnston@gmail.com>
@ 2018-02-22 04:06   ` Tom Lane <tgl@sss.pgh.pa.us>
  2018-02-22 06:57     ` Re: BUG #15076: postmaster crashes unexpectedly when using up arrow key in psql command 趙明春 <mzhao@insight-tec.co.jp>
  1 sibling, 1 reply; 12+ messages in thread

From: Tom Lane @ 2018-02-22 04:06 UTC (permalink / raw)
  To: David G. Johnston <david.g.johnston@gmail.com>; +Cc: mzhao@insight-tec.co.jp <mzhao@insight-tec.co.jp>; pgsql-bugs@lists.postgresql.org <pgsql-bugs@lists.postgresql.org>

"David G. Johnston" <david.g.johnston@gmail.com> writes:
>> The following bug has been logged on the website:
>> (4) press up arrow key to try to execute the previous SQL of the step(2)
>> again
>> (5) Occasionally, it will show you nothing about the SQL, then you can try
>> to input a character ';' and press Enter key, the PostgreSQL will crash
>> unexpectedly

> It would help to explain what you actually see in step 5 instead of just
> saying crash.  In particular is the "failure" in the server or client?

I'd lay long odds that what's being described is a psql crash not a
server crash, and furthermore that the problem is in libreadline
(which is what would be handling up-arrow response).  We've heard
reports before of flaky readline behavior on Windows.  I failed to
find an exact match to this report in a moment's worth of trawling
the archives, though I did find for instance

https://www.postgresql.org/message-id/flat/6a2534f3-4359-617d-d314-17174454eb6d%40orange.fr

I think the questions to ask are around where did this copy of
psql.exe come from, and what version of readline is included in
it, and whether that's up-to-date.

			regards, tom lane




^ permalink  raw  reply  [nested|flat] 12+ messages in thread

* Re: BUG #15076: postmaster crashes unexpectedly when using up arrow key in psql command
  2018-02-22 01:15 BUG #15076: postmaster crashes unexpectedly when using up arrow key in psql command PG Bug reporting form <noreply@postgresql.org>
  2018-02-22 03:29 ` Re: BUG #15076: postmaster crashes unexpectedly when using up arrow key in psql command David G. Johnston <david.g.johnston@gmail.com>
  2018-02-22 04:06   ` Re: BUG #15076: postmaster crashes unexpectedly when using up arrow key in psql command Tom Lane <tgl@sss.pgh.pa.us>
@ 2018-02-22 06:57     ` 趙明春 <mzhao@insight-tec.co.jp>
  2018-02-22 07:57       ` Re: BUG #15076: postmaster crashes unexpectedly when using up arrow key in psql command Michael Paquier <michael@paquier.xyz>
  0 siblings, 1 reply; 12+ messages in thread

From: 趙明春 @ 2018-02-22 06:57 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: David G. Johnston <david.g.johnston@gmail.com>; pgsql-bugs@lists.postgresql.org <pgsql-bugs@lists.postgresql.org>

Hi, Tom,

You mean that the up-arrow key operation in psql.exe may send a SIGINT(or
SIGTERM) signal to server(postmaster) unexpectedly?

Thanks,
Mingchun


-----------------------------------------------------------------------------------
 Insight Technology, Inc.  Mingchun Zhao,  趙 明春(チョウ メイシュン)
  EbisBusinessTower 5F, 1-19-19, Shibuya-ku, Tokyo
  TEL  : +81-3-5475-1452            FAX : +81-3-5475-1451
 Email : mzhao@insight-tec.co.jp    WWW : http://www.insight-tec.com
-----------------------------------------------------------------------------------


2018-02-22 13:06 GMT+09:00 Tom Lane <tgl@sss.pgh.pa.us>:

> "David G. Johnston" <david.g.johnston@gmail.com> writes:
> >> The following bug has been logged on the website:
> >> (4) press up arrow key to try to execute the previous SQL of the step(2)
> >> again
> >> (5) Occasionally, it will show you nothing about the SQL, then you can
> try
> >> to input a character ';' and press Enter key, the PostgreSQL will crash
> >> unexpectedly
>
> > It would help to explain what you actually see in step 5 instead of just
> > saying crash.  In particular is the "failure" in the server or client?
>
> I'd lay long odds that what's being described is a psql crash not a
> server crash, and furthermore that the problem is in libreadline
> (which is what would be handling up-arrow response).  We've heard
> reports before of flaky readline behavior on Windows.  I failed to
> find an exact match to this report in a moment's worth of trawling
> the archives, though I did find for instance
>
> https://www.postgresql.org/message-id/flat/6a2534f3-4359-
> 617d-d314-17174454eb6d%40orange.fr
>
> I think the questions to ask are around where did this copy of
> psql.exe come from, and what version of readline is included in
> it, and whether that's up-to-date.
>
>                         regards, tom lane
>

^ permalink  raw  reply  [nested|flat] 12+ messages in thread

* Re: BUG #15076: postmaster crashes unexpectedly when using up arrow key in psql command
  2018-02-22 01:15 BUG #15076: postmaster crashes unexpectedly when using up arrow key in psql command PG Bug reporting form <noreply@postgresql.org>
  2018-02-22 03:29 ` Re: BUG #15076: postmaster crashes unexpectedly when using up arrow key in psql command David G. Johnston <david.g.johnston@gmail.com>
  2018-02-22 04:06   ` Re: BUG #15076: postmaster crashes unexpectedly when using up arrow key in psql command Tom Lane <tgl@sss.pgh.pa.us>
  2018-02-22 06:57     ` Re: BUG #15076: postmaster crashes unexpectedly when using up arrow key in psql command 趙明春 <mzhao@insight-tec.co.jp>
@ 2018-02-22 07:57       ` Michael Paquier <michael@paquier.xyz>
  2018-02-22 08:24         ` Re: BUG #15076: postmaster crashes unexpectedly when using up arrow key in psql command 趙明春 <mzhao@insight-tec.co.jp>
  0 siblings, 1 reply; 12+ messages in thread

From: Michael Paquier @ 2018-02-22 07:57 UTC (permalink / raw)
  To: 趙明春 <mzhao@insight-tec.co.jp>; +Cc: Tom Lane <tgl@sss.pgh.pa.us>; David G. Johnston <david.g.johnston@gmail.com>; pgsql-bugs@lists.postgresql.org <pgsql-bugs@lists.postgresql.org>

On Thu, Feb 22, 2018 at 03:57:53PM +0900, 趙明春 wrote:
> You mean that the up-arrow key operation in psql.exe may send a SIGINT(or
> SIGTERM) signal to server(postmaster) unexpectedly?

No.  What Tom means here is that you are likely mistaking what you think
is a server crash by a client crash, and that the version of libreadline
your psql version is linked to is buggy and unable to handle that
properly.  psql has no control on the server itself.
--
Michael

Attachments:

  signature.asc (application/pgp-signature, 832B) download

^ permalink  raw  reply  [nested|flat] 12+ messages in thread

* Re: BUG #15076: postmaster crashes unexpectedly when using up arrow key in psql command
  2018-02-22 01:15 BUG #15076: postmaster crashes unexpectedly when using up arrow key in psql command PG Bug reporting form <noreply@postgresql.org>
  2018-02-22 03:29 ` Re: BUG #15076: postmaster crashes unexpectedly when using up arrow key in psql command David G. Johnston <david.g.johnston@gmail.com>
  2018-02-22 04:06   ` Re: BUG #15076: postmaster crashes unexpectedly when using up arrow key in psql command Tom Lane <tgl@sss.pgh.pa.us>
  2018-02-22 06:57     ` Re: BUG #15076: postmaster crashes unexpectedly when using up arrow key in psql command 趙明春 <mzhao@insight-tec.co.jp>
  2018-02-22 07:57       ` Re: BUG #15076: postmaster crashes unexpectedly when using up arrow key in psql command Michael Paquier <michael@paquier.xyz>
@ 2018-02-22 08:24         ` 趙明春 <mzhao@insight-tec.co.jp>
  2018-02-22 15:12           ` Re: BUG #15076: postmaster crashes unexpectedly when using up arrow key in psql command Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 12+ messages in thread

From: 趙明春 @ 2018-02-22 08:24 UTC (permalink / raw)
  To: Michael Paquier <michael@paquier.xyz>; +Cc: Tom Lane <tgl@sss.pgh.pa.us>; David G. Johnston <david.g.johnston@gmail.com>; pgsql-bugs@lists.postgresql.org <pgsql-bugs@lists.postgresql.org>

 Hi, Michael, Thanks. I got what you mean.

Anyway, the postmaster was received signal 2 in step 5 as below.

(1) run psql.exe in a Windows Command Prompt
(2) execute a SQL with more than one page of results, e.g. `show all;`
(3) press Ctrl + C to break it on the first page
(4) press up arrow key to try to execute the previous SQL of the step(2)
again
(5) Occasionally, it will show you nothing about the SQL, then you can try
to input a character ';' and press Enter key, the PostgreSQL will crash
unexpectedly

So, Let me change my question:
If I started the PostgreSQL by pg_ctl command in the same Windows command
prompt,
Is it possible that pressing Ctrl + C on psql to break query(not session)
will send SIGINT to postmaster process unexpectedly?

Best Regards,
Mingchun

-----------------------------------------------------------------------------------
 Insight Technology, Inc.  Mingchun Zhao,  趙 明春(チョウ メイシュン)
  EbisBusinessTower 5F, 1-19-19, Shibuya-ku, Tokyo
  TEL  : +81-3-5475-1452            FAX : +81-3-5475-1451
 Email : mzhao@insight-tec.co.jp    WWW : http://www.insight-tec.com
-----------------------------------------------------------------------------------


2018-02-22 16:57 GMT+09:00 Michael Paquier <michael@paquier.xyz>:

> On Thu, Feb 22, 2018 at 03:57:53PM +0900, 趙明春 wrote:
> > You mean that the up-arrow key operation in psql.exe may send a SIGINT(or
> > SIGTERM) signal to server(postmaster) unexpectedly?
>
> No.  What Tom means here is that you are likely mistaking what you think
> is a server crash by a client crash, and that the version of libreadline
> your psql version is linked to is buggy and unable to handle that
> properly.  psql has no control on the server itself.
> --
> Michael
>

^ permalink  raw  reply  [nested|flat] 12+ messages in thread

* Re: BUG #15076: postmaster crashes unexpectedly when using up arrow key in psql command
  2018-02-22 01:15 BUG #15076: postmaster crashes unexpectedly when using up arrow key in psql command PG Bug reporting form <noreply@postgresql.org>
  2018-02-22 03:29 ` Re: BUG #15076: postmaster crashes unexpectedly when using up arrow key in psql command David G. Johnston <david.g.johnston@gmail.com>
  2018-02-22 04:06   ` Re: BUG #15076: postmaster crashes unexpectedly when using up arrow key in psql command Tom Lane <tgl@sss.pgh.pa.us>
  2018-02-22 06:57     ` Re: BUG #15076: postmaster crashes unexpectedly when using up arrow key in psql command 趙明春 <mzhao@insight-tec.co.jp>
  2018-02-22 07:57       ` Re: BUG #15076: postmaster crashes unexpectedly when using up arrow key in psql command Michael Paquier <michael@paquier.xyz>
  2018-02-22 08:24         ` Re: BUG #15076: postmaster crashes unexpectedly when using up arrow key in psql command 趙明春 <mzhao@insight-tec.co.jp>
@ 2018-02-22 15:12           ` Tom Lane <tgl@sss.pgh.pa.us>
  2018-02-22 19:35             ` Re: BUG #15076: postmaster crashes unexpectedly when using up arrow key in psql command Magnus Hagander <magnus@hagander.net>
  0 siblings, 1 reply; 12+ messages in thread

From: Tom Lane @ 2018-02-22 15:12 UTC (permalink / raw)
  To: 趙明春 <mzhao@insight-tec.co.jp>; +Cc: Michael Paquier <michael@paquier.xyz>; David G. Johnston <david.g.johnston@gmail.com>; pgsql-bugs@lists.postgresql.org <pgsql-bugs@lists.postgresql.org>

=?UTF-8?B?6LaZ5piO5pil?= <mzhao@insight-tec.co.jp> writes:
> So, Let me change my question:
> If I started the PostgreSQL by pg_ctl command in the same Windows command
> prompt,
> Is it possible that pressing Ctrl + C on psql to break query(not session)
> will send SIGINT to postmaster process unexpectedly?

I don't know much about Windows signal processing, but the log entries you
show certainly look like that's what happened.

On Unix-ish machines it's normal for control-C to send a SIGINT to every
process that's in the terminal's process group --- *not* just the
foreground process.  So if you launch the postmaster manually you'd better
make sure that it gets dissociated from the terminal, or you're at risk
of killing it accidentally.  (Or, if you want to leave it connected to
that terminal, you use another window to run psql etc.)  It seems that
something similar is happening on your Windows setup.  I don't know
the rules for process/terminal association on Windows, so I can't suggest
what's the right way to do it.  I will say though that most people
run the postmaster as a background service on Windows, rather than
launching it manually.

			regards, tom lane




^ permalink  raw  reply  [nested|flat] 12+ messages in thread

* Re: BUG #15076: postmaster crashes unexpectedly when using up arrow key in psql command
  2018-02-22 01:15 BUG #15076: postmaster crashes unexpectedly when using up arrow key in psql command PG Bug reporting form <noreply@postgresql.org>
  2018-02-22 03:29 ` Re: BUG #15076: postmaster crashes unexpectedly when using up arrow key in psql command David G. Johnston <david.g.johnston@gmail.com>
  2018-02-22 04:06   ` Re: BUG #15076: postmaster crashes unexpectedly when using up arrow key in psql command Tom Lane <tgl@sss.pgh.pa.us>
  2018-02-22 06:57     ` Re: BUG #15076: postmaster crashes unexpectedly when using up arrow key in psql command 趙明春 <mzhao@insight-tec.co.jp>
  2018-02-22 07:57       ` Re: BUG #15076: postmaster crashes unexpectedly when using up arrow key in psql command Michael Paquier <michael@paquier.xyz>
  2018-02-22 08:24         ` Re: BUG #15076: postmaster crashes unexpectedly when using up arrow key in psql command 趙明春 <mzhao@insight-tec.co.jp>
  2018-02-22 15:12           ` Re: BUG #15076: postmaster crashes unexpectedly when using up arrow key in psql command Tom Lane <tgl@sss.pgh.pa.us>
@ 2018-02-22 19:35             ` Magnus Hagander <magnus@hagander.net>
  2018-02-23 02:16               ` Re: BUG #15076: postmaster crashes unexpectedly when using up arrow key in psql command 趙明春 <mzhao@insight-tec.co.jp>
  0 siblings, 1 reply; 12+ messages in thread

From: Magnus Hagander @ 2018-02-22 19:35 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: 趙明春 <mzhao@insight-tec.co.jp>; Michael Paquier <michael@paquier.xyz>; David G. Johnston <david.g.johnston@gmail.com>; pgsql-bugs@lists.postgresql.org <pgsql-bugs@lists.postgresql.org>

On Thu, Feb 22, 2018 at 4:12 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:

> =?UTF-8?B?6LaZ5piO5pil?= <mzhao@insight-tec.co.jp> writes:
> > So, Let me change my question:
> > If I started the PostgreSQL by pg_ctl command in the same Windows command
> > prompt,
> > Is it possible that pressing Ctrl + C on psql to break query(not session)
> > will send SIGINT to postmaster process unexpectedly?
>
> I don't know much about Windows signal processing, but the log entries you
> show certainly look like that's what happened.
>

Yes, this is unfortunately exactly how it works on Windows.

There is on way to intercept the Ctrl-C and have it not delivered to *all*
processes out of the same session. It can only be added or removed for the
current process (which psql does). So it gets delivered to the backends
which call pg_console_handler, which emulates SIGINT.


On Unix-ish machines it's normal for control-C to send a SIGINT to every
> process that's in the terminal's process group --- *not* just the
> foreground process.  So if you launch the postmaster manually you'd better
> make sure that it gets dissociated from the terminal, or you're at risk
> of killing it accidentally.  (Or, if you want to leave it connected to
> that terminal, you use another window to run psql etc.)  It seems that
> something similar is happening on your Windows setup.  I don't know
> the rules for process/terminal association on Windows, so I can't suggest
> what's the right way to do it.  I will say though that most people
> run the postmaster as a background service on Windows, rather than
> launching it manually.
>

AFAIC Windows has no way to disassociate a process with a console window in
a similar way.


-- 
 Magnus Hagander
 Me: https://www.hagander.net/ <http://www.hagander.net/;
 Work: https://www.redpill-linpro.com/ <http://www.redpill-linpro.com/;

^ permalink  raw  reply  [nested|flat] 12+ messages in thread

* Re: BUG #15076: postmaster crashes unexpectedly when using up arrow key in psql command
  2018-02-22 01:15 BUG #15076: postmaster crashes unexpectedly when using up arrow key in psql command PG Bug reporting form <noreply@postgresql.org>
  2018-02-22 03:29 ` Re: BUG #15076: postmaster crashes unexpectedly when using up arrow key in psql command David G. Johnston <david.g.johnston@gmail.com>
  2018-02-22 04:06   ` Re: BUG #15076: postmaster crashes unexpectedly when using up arrow key in psql command Tom Lane <tgl@sss.pgh.pa.us>
  2018-02-22 06:57     ` Re: BUG #15076: postmaster crashes unexpectedly when using up arrow key in psql command 趙明春 <mzhao@insight-tec.co.jp>
  2018-02-22 07:57       ` Re: BUG #15076: postmaster crashes unexpectedly when using up arrow key in psql command Michael Paquier <michael@paquier.xyz>
  2018-02-22 08:24         ` Re: BUG #15076: postmaster crashes unexpectedly when using up arrow key in psql command 趙明春 <mzhao@insight-tec.co.jp>
  2018-02-22 15:12           ` Re: BUG #15076: postmaster crashes unexpectedly when using up arrow key in psql command Tom Lane <tgl@sss.pgh.pa.us>
  2018-02-22 19:35             ` Re: BUG #15076: postmaster crashes unexpectedly when using up arrow key in psql command Magnus Hagander <magnus@hagander.net>
@ 2018-02-23 02:16               ` 趙明春 <mzhao@insight-tec.co.jp>
  2018-02-24 22:09                 ` Re: BUG #15076: postmaster crashes unexpectedly when using up arrow key in psql command Magnus Hagander <magnus@hagander.net>
  0 siblings, 1 reply; 12+ messages in thread

From: 趙明春 @ 2018-02-23 02:16 UTC (permalink / raw)
  To: Magnus Hagander <magnus@hagander.net>; +Cc: Tom Lane <tgl@sss.pgh.pa.us>; Michael Paquier <michael@paquier.xyz>; David G. Johnston <david.g.johnston@gmail.com>; pgsql-bugs@lists.postgresql.org <pgsql-bugs@lists.postgresql.org>

Hi, Tom and Magnus,

Thanks for your information for this issue.

> AFAIC Windows has no way to disassociate a process with a console window
in a similar way.

Can this be a solution for this issue to add an option
CREATE_NEW_PROCESS_GROUP to CreateProcess() function into pg_ctl.exe to
start postgres.exe process?

>  I will say though that most people run the postmaster as a background
service on Windows, rather than launching it manually.

Unfortunately, we also met this issue, with poor reproducibility, when we
running the postmaster as Windows Service.
Maybe this is another story than launching it manually by pg_ctl.exe.
I will update you if I get any new information.

BEST,

-----------------------------------------------------------------------------------
 Insight Technology, Inc.  Mingchun Zhao,  趙 明春(チョウ メイシュン)
  EbisBusinessTower 5F, 1-19-19, Shibuya-ku, Tokyo
  TEL  : +81-3-5475-1452            FAX : +81-3-5475-1451
 Email : mzhao@insight-tec.co.jp    WWW : http://www.insight-tec.com
-----------------------------------------------------------------------------------


2018-02-23 4:35 GMT+09:00 Magnus Hagander <magnus@hagander.net>:

>
>
> On Thu, Feb 22, 2018 at 4:12 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>
>> =?UTF-8?B?6LaZ5piO5pil?= <mzhao@insight-tec.co.jp> writes:
>> > So, Let me change my question:
>> > If I started the PostgreSQL by pg_ctl command in the same Windows
>> command
>> > prompt,
>> > Is it possible that pressing Ctrl + C on psql to break query(not
>> session)
>> > will send SIGINT to postmaster process unexpectedly?
>>
>> I don't know much about Windows signal processing, but the log entries you
>> show certainly look like that's what happened.
>>
>
> Yes, this is unfortunately exactly how it works on Windows.
>
> There is on way to intercept the Ctrl-C and have it not delivered to *all*
> processes out of the same session. It can only be added or removed for the
> current process (which psql does). So it gets delivered to the backends
> which call pg_console_handler, which emulates SIGINT.
>
>
> On Unix-ish machines it's normal for control-C to send a SIGINT to every
>> process that's in the terminal's process group --- *not* just the
>> foreground process.  So if you launch the postmaster manually you'd better
>> make sure that it gets dissociated from the terminal, or you're at risk
>> of killing it accidentally.  (Or, if you want to leave it connected to
>> that terminal, you use another window to run psql etc.)  It seems that
>> something similar is happening on your Windows setup.  I don't know
>> the rules for process/terminal association on Windows, so I can't suggest
>> what's the right way to do it.  I will say though that most people
>> run the postmaster as a background service on Windows, rather than
>> launching it manually.
>>
>
> AFAIC Windows has no way to disassociate a process with a console window
> in a similar way.
>
>
> --
>  Magnus Hagander
>  Me: https://www.hagander.net/ <http://www.hagander.net/;
>  Work: https://www.redpill-linpro.com/ <http://www.redpill-linpro.com/;
>

^ permalink  raw  reply  [nested|flat] 12+ messages in thread

* Re: BUG #15076: postmaster crashes unexpectedly when using up arrow key in psql command
  2018-02-22 01:15 BUG #15076: postmaster crashes unexpectedly when using up arrow key in psql command PG Bug reporting form <noreply@postgresql.org>
  2018-02-22 03:29 ` Re: BUG #15076: postmaster crashes unexpectedly when using up arrow key in psql command David G. Johnston <david.g.johnston@gmail.com>
  2018-02-22 04:06   ` Re: BUG #15076: postmaster crashes unexpectedly when using up arrow key in psql command Tom Lane <tgl@sss.pgh.pa.us>
  2018-02-22 06:57     ` Re: BUG #15076: postmaster crashes unexpectedly when using up arrow key in psql command 趙明春 <mzhao@insight-tec.co.jp>
  2018-02-22 07:57       ` Re: BUG #15076: postmaster crashes unexpectedly when using up arrow key in psql command Michael Paquier <michael@paquier.xyz>
  2018-02-22 08:24         ` Re: BUG #15076: postmaster crashes unexpectedly when using up arrow key in psql command 趙明春 <mzhao@insight-tec.co.jp>
  2018-02-22 15:12           ` Re: BUG #15076: postmaster crashes unexpectedly when using up arrow key in psql command Tom Lane <tgl@sss.pgh.pa.us>
  2018-02-22 19:35             ` Re: BUG #15076: postmaster crashes unexpectedly when using up arrow key in psql command Magnus Hagander <magnus@hagander.net>
  2018-02-23 02:16               ` Re: BUG #15076: postmaster crashes unexpectedly when using up arrow key in psql command 趙明春 <mzhao@insight-tec.co.jp>
@ 2018-02-24 22:09                 ` Magnus Hagander <magnus@hagander.net>
  2018-02-25 07:14                   ` Re: BUG #15076: postmaster crashes unexpectedly when using up arrow key in psql command 趙明春 <mzhao@insight-tec.co.jp>
  0 siblings, 1 reply; 12+ messages in thread

From: Magnus Hagander @ 2018-02-24 22:09 UTC (permalink / raw)
  To: 趙明春 <mzhao@insight-tec.co.jp>; +Cc: Tom Lane <tgl@sss.pgh.pa.us>; Michael Paquier <michael@paquier.xyz>; David G. Johnston <david.g.johnston@gmail.com>; pgsql-bugs@lists.postgresql.org <pgsql-bugs@lists.postgresql.org>

On Fri, Feb 23, 2018 at 3:16 AM, 趙明春 <mzhao@insight-tec.co.jp> wrote:

> Hi, Tom and Magnus,
>
> Thanks for your information for this issue.
>
> > AFAIC Windows has no way to disassociate a process with a console window
> in a similar way.
>
> Can this be a solution for this issue to add an option
> CREATE_NEW_PROCESS_GROUP to CreateProcess() function into pg_ctl.exe to
> start postgres.exe process?
>

That definitely sounds like it should be worth a try.


>  I will say though that most people run the postmaster as a background
> service on Windows, rather than launching it manually.
>
> Unfortunately, we also met this issue, with poor reproducibility, when we
> running the postmaster as Windows Service.
> Maybe this is another story than launching it manually by pg_ctl.exe.
> I will update you if I get any new information.
>
>
That sounds very strange. I'm not saying you're not running into an issue
there, but my guess would be you're actually running into a different
problem (which may have similar symptoms).

//Magnus

^ permalink  raw  reply  [nested|flat] 12+ messages in thread

* Re: BUG #15076: postmaster crashes unexpectedly when using up arrow key in psql command
  2018-02-22 01:15 BUG #15076: postmaster crashes unexpectedly when using up arrow key in psql command PG Bug reporting form <noreply@postgresql.org>
  2018-02-22 03:29 ` Re: BUG #15076: postmaster crashes unexpectedly when using up arrow key in psql command David G. Johnston <david.g.johnston@gmail.com>
  2018-02-22 04:06   ` Re: BUG #15076: postmaster crashes unexpectedly when using up arrow key in psql command Tom Lane <tgl@sss.pgh.pa.us>
  2018-02-22 06:57     ` Re: BUG #15076: postmaster crashes unexpectedly when using up arrow key in psql command 趙明春 <mzhao@insight-tec.co.jp>
  2018-02-22 07:57       ` Re: BUG #15076: postmaster crashes unexpectedly when using up arrow key in psql command Michael Paquier <michael@paquier.xyz>
  2018-02-22 08:24         ` Re: BUG #15076: postmaster crashes unexpectedly when using up arrow key in psql command 趙明春 <mzhao@insight-tec.co.jp>
  2018-02-22 15:12           ` Re: BUG #15076: postmaster crashes unexpectedly when using up arrow key in psql command Tom Lane <tgl@sss.pgh.pa.us>
  2018-02-22 19:35             ` Re: BUG #15076: postmaster crashes unexpectedly when using up arrow key in psql command Magnus Hagander <magnus@hagander.net>
  2018-02-23 02:16               ` Re: BUG #15076: postmaster crashes unexpectedly when using up arrow key in psql command 趙明春 <mzhao@insight-tec.co.jp>
  2018-02-24 22:09                 ` Re: BUG #15076: postmaster crashes unexpectedly when using up arrow key in psql command Magnus Hagander <magnus@hagander.net>
@ 2018-02-25 07:14                   ` 趙明春 <mzhao@insight-tec.co.jp>
  0 siblings, 0 replies; 12+ messages in thread

From: 趙明春 @ 2018-02-25 07:14 UTC (permalink / raw)
  To: Magnus Hagander <magnus@hagander.net>; +Cc: Tom Lane <tgl@sss.pgh.pa.us>; Michael Paquier <michael@paquier.xyz>; David G. Johnston <david.g.johnston@gmail.com>; pgsql-bugs@lists.postgresql.org <pgsql-bugs@lists.postgresql.org>

Hi, Magnus,

> That definitely sounds like it should be worth a try.

Sounds good. I'll try to make a patch for it.

> That sounds very strange. I'm not saying you're not running into an issue
there, but my guess would be you're actually running into a different
problem (which may have similar symptoms).

I see, I'll look into the way to reproduce the same symptom.

Thanks,
Mingchun

-----------------------------------------------------------------------------------
 Insight Technology, Inc.  Mingchun Zhao,  趙 明春(チョウ メイシュン)
  EbisBusinessTower 5F, 1-19-19, Shibuya-ku, Tokyo
  TEL  : +81-3-5475-1452            FAX : +81-3-5475-1451
 Email : mzhao@insight-tec.co.jp    WWW : http://www.insight-tec.com
-----------------------------------------------------------------------------------


2018-02-25 7:09 GMT+09:00 Magnus Hagander <magnus@hagander.net>:

> On Fri, Feb 23, 2018 at 3:16 AM, 趙明春 <mzhao@insight-tec.co.jp> wrote:
>
>> Hi, Tom and Magnus,
>>
>> Thanks for your information for this issue.
>>
>> > AFAIC Windows has no way to disassociate a process with a console
>> window in a similar way.
>>
>> Can this be a solution for this issue to add an option
>> CREATE_NEW_PROCESS_GROUP to CreateProcess() function into pg_ctl.exe to
>> start postgres.exe process?
>>
>
> That definitely sounds like it should be worth a try.
>
>
> >  I will say though that most people run the postmaster as a background
>> service on Windows, rather than launching it manually.
>>
>> Unfortunately, we also met this issue, with poor reproducibility, when we
>> running the postmaster as Windows Service.
>> Maybe this is another story than launching it manually by pg_ctl.exe.
>> I will update you if I get any new information.
>>
>>
> That sounds very strange. I'm not saying you're not running into an issue
> there, but my guess would be you're actually running into a different
> problem (which may have similar symptoms).
>
> //Magnus
>
>

^ permalink  raw  reply  [nested|flat] 12+ messages in thread

* Re: BUG #15076: postmaster crashes unexpectedly when using up arrow key in psql command
  2018-02-22 01:15 BUG #15076: postmaster crashes unexpectedly when using up arrow key in psql command PG Bug reporting form <noreply@postgresql.org>
  2018-02-22 03:29 ` Re: BUG #15076: postmaster crashes unexpectedly when using up arrow key in psql command David G. Johnston <david.g.johnston@gmail.com>
@ 2018-02-22 06:45   ` 趙明春 <mzhao@insight-tec.co.jp>
  1 sibling, 0 replies; 12+ messages in thread

From: 趙明春 @ 2018-02-22 06:45 UTC (permalink / raw)
  To: David G. Johnston <david.g.johnston@gmail.com>; +Cc: pgsql-bugs@lists.postgresql.org <pgsql-bugs@lists.postgresql.org>

​​Hi, david,

> It would help to explain what you actually see in step 5 instead of just
saying crash.  In particular is the "failure" in the server or client?

It looks like the postmaster has received signal 2 in step 5, the following
is the corresponding PostgreSQL log:
==
0000: 2018-02-19 15:37:34 JST [3492]: [65-1] user = ,db = ,remote =  app =
DEBUG:  postmaster received signal 2
00000: 2018-02-19 15:37:34 JST [3492]: [66-1] user = ,db = ,remote =  app
=  LOG:  received fast shutdown request
00000: 2018-02-19 15:37:34 JST [3492]: [67-1] user = ,db = ,remote =  app
=  LOG:  aborting any active transactions
==

​Regards,
Mingchun​


2018-02-22 12:29 GMT+09:00 David G. Johnston <david.g.johnston@gmail.com>:

>
>
> On Wednesday, February 21, 2018, PG Bug reporting form <
> noreply@postgresql.org> wrote:
>
>> The following bug has been logged on the website:
>>
>> Bug reference:      15076
>> Logged by:          Mingchun Zhao
>> Email address:      mzhao@insight-tec.co.jp
>> PostgreSQL version: 9.3.20
>> Operating system:   Windows
>> Description:
>>
>> steps to reproduce:
>>
>> (1) run psql.exe in a Windows Command Prompt
>> (2) execute a SQL with more than one page of results, e.g. `show all;`
>> (3) press Ctrl + C to break it on the first page
>> (4) press up arrow key to try to execute the previous SQL of the step(2)
>> again
>> (5) Occasionally, it will show you nothing about the SQL, then you can try
>> to input a character ';' and press Enter key, the PostgreSQL will crash
>> unexpectedly
>>
>>
> It would help to explain what you actually see in step 5 instead of just
> saying crash.  In particular is the "failure" in the server or client?
>
> David J.
>

^ permalink  raw  reply  [nested|flat] 12+ messages in thread


end of thread, other threads:[~2018-02-25 07:14 UTC | newest]

Thread overview: 12+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2018-02-22 01:15 BUG #15076: postmaster crashes unexpectedly when using up arrow key in psql command PG Bug reporting form <noreply@postgresql.org>
2018-02-22 03:29 ` David G. Johnston <david.g.johnston@gmail.com>
2018-02-22 04:06   ` Tom Lane <tgl@sss.pgh.pa.us>
2018-02-22 06:57     ` 趙明春 <mzhao@insight-tec.co.jp>
2018-02-22 07:57       ` Michael Paquier <michael@paquier.xyz>
2018-02-22 08:24         ` 趙明春 <mzhao@insight-tec.co.jp>
2018-02-22 15:12           ` Tom Lane <tgl@sss.pgh.pa.us>
2018-02-22 19:35             ` Magnus Hagander <magnus@hagander.net>
2018-02-23 02:16               ` 趙明春 <mzhao@insight-tec.co.jp>
2018-02-24 22:09                 ` Magnus Hagander <magnus@hagander.net>
2018-02-25 07:14                   ` 趙明春 <mzhao@insight-tec.co.jp>
2018-02-22 06:45   ` 趙明春 <mzhao@insight-tec.co.jp>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox