Re: [HACKERS] Postgres service stops when I kill client backend on Windows

2015-10-13 Thread Amit Kapila
On Tue, Oct 13, 2015 at 8:57 PM, Tom Lane wrote: > > Michael Paquier writes: > > On Tue, Oct 13, 2015 at 5:35 AM, Tom Lane wrote: > >> After poking around a bit more, I propose the attached patch. I've > >> checked that this is

Re: [HACKERS] Postgres service stops when I kill client backend on Windows

2015-10-13 Thread Michael Paquier
On Tue, Oct 13, 2015 at 5:35 AM, Tom Lane wrote: > I wrote: >> This is kind of a mess :-(. But it does look like what we want is >> for SubPostmasterMain to do more than nothing when it chooses not to >> reattach. Probably that should include resetting UsedShmemSegAddr to >>

Re: [HACKERS] Postgres service stops when I kill client backend on Windows

2015-10-13 Thread Andrew Dunstan
On 10/12/2015 04:35 PM, Tom Lane wrote: I wrote: This is kind of a mess :-(. But it does look like what we want is for SubPostmasterMain to do more than nothing when it chooses not to reattach. Probably that should include resetting UsedShmemSegAddr to NULL, as well as closing the handle.

Re: [HACKERS] Postgres service stops when I kill client backend on Windows

2015-10-13 Thread Tom Lane
Andrew Dunstan writes: > On 10/12/2015 04:35 PM, Tom Lane wrote: >> BTW, it appears from this that Cygwin builds have been broken right along >> in a different way: according to the code in sysv_shmem's >> PGSharedMemoryReAttach, Cygwin does cause a re-attach to occur, which

Re: [HACKERS] Postgres service stops when I kill client backend on Windows

2015-10-13 Thread Tom Lane
Michael Paquier writes: > On Tue, Oct 13, 2015 at 5:35 AM, Tom Lane wrote: >> After poking around a bit more, I propose the attached patch. I've >> checked that this is happy with an EXEC_BACKEND Unix build, but I'm not >> able to test it on

Re: [HACKERS] Postgres service stops when I kill client backend on Windows

2015-10-12 Thread Magnus Hagander
On Mon, Oct 12, 2015 at 12:25 PM, Andres Freund wrote: > On 2015-10-12 11:25:35 +0530, Amit Kapila wrote: > > /* > > + * Close the shared memory handle as the syslogger doesn't need to > > + * attach to it. For EXEC_BACKEND case, the shared memory handle > >

Re: [HACKERS] Postgres service stops when I kill client backend on Windows

2015-10-12 Thread Andres Freund
On 2015-10-12 11:25:35 +0530, Amit Kapila wrote: > /* > + * Close the shared memory handle as the syslogger doesn't need to > + * attach to it. For EXEC_BACKEND case, the shared memory handle > + * is inherited by all postmaster child processes irrespective of > + *

Re: [HACKERS] Postgres service stops when I kill client backend on Windows

2015-10-12 Thread Amit Kapila
On Mon, Oct 12, 2015 at 3:45 PM, Michael Paquier wrote: > > On Mon, Oct 12, 2015 at 2:55 PM, Amit Kapila wrote: > > On Sun, Oct 11, 2015 at 9:12 PM, Tom Lane wrote: > > I could easily reproduce the issue if logging

Re: [HACKERS] Postgres service stops when I kill client backend on Windows

2015-10-12 Thread Michael Paquier
On Mon, Oct 12, 2015 at 2:55 PM, Amit Kapila wrote: > On Sun, Oct 11, 2015 at 9:12 PM, Tom Lane wrote: > I could easily reproduce the issue if logging collector is on and even if > we try to increase the loop count or sleep time in

Re: [HACKERS] Postgres service stops when I kill client backend on Windows

2015-10-12 Thread Michael Paquier
On Mon, Oct 12, 2015 at 7:26 PM, Magnus Hagander wrote: > > > On Mon, Oct 12, 2015 at 12:25 PM, Andres Freund wrote: >> >> On 2015-10-12 11:25:35 +0530, Amit Kapila wrote: >> > /* >> > + * Close the shared memory handle as the syslogger doesn't

Re: [HACKERS] Postgres service stops when I kill client backend on Windows

2015-10-12 Thread Andres Freund
On 2015-10-12 21:38:12 +0900, Michael Paquier wrote: > >> It feels wrong to do this in syslogger.c - I mean it's not the only > >> process that's not attached to shared memory. Sure, the others get > >> killed, but nonetheless... > > > > > > +1. It feels like we're setting our selves up for

Re: [HACKERS] Postgres service stops when I kill client backend on Windows

2015-10-12 Thread Dmitry Vasilyev
Hello, Amit! On Пн, 2015-10-12 at 11:25 +0530, Amit Kapila wrote: > On Sun, Oct 11, 2015 at 9:12 PM, Tom Lane wrote: > > > > Magnus Hagander writes: > > > On Sun, Oct 11, 2015 at 5:22 PM, Tom Lane > wrote: > > >> I'm a bit suspicious

Re: [HACKERS] Postgres service stops when I kill client backend on Windows

2015-10-12 Thread Andres Freund
On 2015-10-12 10:04:55 -0400, Tom Lane wrote: > Andres Freund writes: > > On 2015-10-12 21:38:12 +0900, Michael Paquier wrote: > >> Actually, doesn't this apply as well to the archiver and the pgstat > >> collector? > > > As mentioned above? The difference is that the

Re: [HACKERS] Postgres service stops when I kill client backend on Windows

2015-10-12 Thread Tom Lane
Andres Freund writes: > Right. But that doesn't mean it's right to call PGSharedMemoryDetach() > without other changes as done in Michael's proposed patch? That'll do an > UnmapViewOfFile() which'll fail because nothing i mapped, but still not > close UsedShmemSegID? Ah,

Re: [HACKERS] Postgres service stops when I kill client backend on Windows

2015-10-12 Thread Amit Kapila
On Mon, Oct 12, 2015 at 8:10 PM, Tom Lane wrote: > > I wrote: > > Andres Freund writes: > >> Right. But that doesn't mean it's right to call PGSharedMemoryDetach() > >> without other changes as done in Michael's proposed patch? That'll do an > >>

Re: [HACKERS] Postgres service stops when I kill client backend on Windows

2015-10-12 Thread Tom Lane
I wrote: > Actually, now that I look at it, it's even more obvious that this is the > wrong thing because *all the subprocess types in question already call > PGSharedMemoryDetach*. Ah, scratch that: in most of them, the call is in #ifndef EXEC_BACKEND stanzas. The exception is bgworker start

Re: [HACKERS] Postgres service stops when I kill client backend on Windows

2015-10-12 Thread Tom Lane
Oleg Bartunov writes: > Assuming the problem will be fixed, should we release Beta2 soon ? This bug has existed since we had native Windows support. It's entirely immaterial for beta purposes, and I have a hard time thinking it's critical enough to justify a short release

Re: [HACKERS] Postgres service stops when I kill client backend on Windows

2015-10-12 Thread Oleg Bartunov
On Mon, Oct 12, 2015 at 4:42 PM, Dmitry Vasilyev wrote: > Hello, Amit! > > On Пн, 2015-10-12 at 11:25 +0530, Amit Kapila wrote: > > On Sun, Oct 11, 2015 at 9:12 PM, Tom Lane wrote: > > > > Magnus Hagander writes: > > > On Sun,

Re: [HACKERS] Postgres service stops when I kill client backend on Windows

2015-10-12 Thread Tom Lane
Andres Freund writes: > On 2015-10-12 21:38:12 +0900, Michael Paquier wrote: >> Actually, doesn't this apply as well to the archiver and the pgstat >> collector? > As mentioned above? The difference is that the archiver et al get killed > by postmaster during a PANIC restart

Re: [HACKERS] Postgres service stops when I kill client backend on Windows

2015-10-12 Thread Tom Lane
I wrote: > Andres Freund writes: >> Right. But that doesn't mean it's right to call PGSharedMemoryDetach() >> without other changes as done in Michael's proposed patch? That'll do an >> UnmapViewOfFile() which'll fail because nothing i mapped, but still not >> close

Re: [HACKERS] Postgres service stops when I kill client backend on Windows

2015-10-12 Thread Tom Lane
I wrote: > This is kind of a mess :-(. But it does look like what we want is > for SubPostmasterMain to do more than nothing when it chooses not to > reattach. Probably that should include resetting UsedShmemSegAddr to > NULL, as well as closing the handle. After poking around a bit more, I

Re: [HACKERS] Postgres service stops when I kill client backend on Windows

2015-10-12 Thread Dmitry Vasilyev
Hello Tom! On Пн, 2015-10-12 at 16:35 -0400, Tom Lane wrote: > I wrote: > > This is kind of a mess :-(.  But it does look like what we want is > > for SubPostmasterMain to do more than nothing when it chooses not > > to > > reattach.  Probably that should include resetting UsedShmemSegAddr > > to

Re: [HACKERS] Postgres service stops when I kill client backend on Windows

2015-10-11 Thread Magnus Hagander
On Sun, Oct 11, 2015 at 5:55 AM, Michael Paquier wrote: > On Sun, Oct 11, 2015 at 8:54 AM, Ali Akbar wrote: > > C:\Windows\system32>taskkill /F /PID 2080 > > SUCCESS: The process with PID 2080 has been terminated. > > taskkill /f *forcefully*

Re: [HACKERS] Postgres service stops when I kill client backend on Windows

2015-10-11 Thread Amit Kapila
On Sun, Oct 11, 2015 at 10:09 AM, Tom Lane wrote: > Dmitry Vasilyev writes: > > The log you can see bellow: > > ... > > 2015-10-10 19:00:32 AST DEBUG: cleaning up dynamic shared memory control segment with ID 851401618 > > 2015-10-10 19:00:32 AST

Re: [HACKERS] Postgres service stops when I kill client backend on Windows

2015-10-11 Thread Tom Lane
Magnus Hagander writes: > On Sun, Oct 11, 2015 at 5:22 PM, Tom Lane wrote: >> I'm a bit suspicious that we may have leaked a handle to the shared >> memory block someplace, for example. That would explain why this >> symptom is visible now when it was

Re: [HACKERS] Postgres service stops when I kill client backend on Windows

2015-10-11 Thread Tom Lane
Andrew Dunstan writes: > Amit's proposals elsewhere to increase the shmem timeout and increase > logging seem reasonable. I'm back to the position I had in the previous thread, which is that we don't really understand why any delay is needed here at all, and we ought to try

Re: [HACKERS] Postgres service stops when I kill client backend on Windows

2015-10-11 Thread Andrew Dunstan
On 10/11/2015 05:58 AM, Magnus Hagander wrote: On Sun, Oct 11, 2015 at 5:55 AM, Michael Paquier > wrote: On Sun, Oct 11, 2015 at 8:54 AM, Ali Akbar > wrote: >

Re: [HACKERS] Postgres service stops when I kill client backend on Windows

2015-10-11 Thread Magnus Hagander
On Sun, Oct 11, 2015 at 4:32 PM, Andrew Dunstan wrote: > > > On 10/11/2015 05:58 AM, Magnus Hagander wrote: > >> >> >> On Sun, Oct 11, 2015 at 5:55 AM, Michael Paquier < >> michael.paqu...@gmail.com > wrote: >> >> On Sun, Oct 11, 2015 at

Re: [HACKERS] Postgres service stops when I kill client backend on Windows

2015-10-11 Thread Magnus Hagander
On Sun, Oct 11, 2015 at 5:22 PM, Tom Lane wrote: > Andrew Dunstan writes: > > Amit's proposals elsewhere to increase the shmem timeout and increase > > logging seem reasonable. > > I'm back to the position I had in the previous thread, which is that > we

Re: [HACKERS] Postgres service stops when I kill client backend on Windows

2015-10-11 Thread Michael Paquier
> On Sun, Oct 11, 2015 at 5:55 AM, Michael Paquier wrote: >> On Sun, Oct 11, 2015 at 8:54 AM, Ali Akbar wrote: >> > C:\Windows\system32>taskkill /F /PID 2080 >> > SUCCESS: The process with PID 2080 has been terminated. >> >> taskkill /f *forcefully* terminates the process

Re: [HACKERS] Postgres service stops when I kill client backend on Windows

2015-10-11 Thread Amit Kapila
On Sun, Oct 11, 2015 at 9:12 PM, Tom Lane wrote: > > Magnus Hagander writes: > > On Sun, Oct 11, 2015 at 5:22 PM, Tom Lane wrote: > >> I'm a bit suspicious that we may have leaked a handle to the shared > >> memory block someplace,

Re: [HACKERS] Postgres service stops when I kill client backend on Windows

2015-10-10 Thread Tom Lane
Robert Haas writes: > On Fri, Oct 9, 2015 at 5:52 AM, Dmitry Vasilyev >> postgres=# select 1; >> server closed the connection unexpectedly >> This probably means the server terminated abnormally >> before or while processing the request. >> The connection to the server was

Re: [HACKERS] Postgres service stops when I kill client backend on Windows

2015-10-10 Thread Tom Lane
Dmitry Vasilyev writes: > I have written, what service stopped. This action is repeatable. > You can run command 'psql -c "do $$ unpack p,1x8 $$ language plperlu;"' > and after this windows service will stop. Well, (a) that probably means that your plperl installation

Re: [HACKERS] Postgres service stops when I kill client backend on Windows

2015-10-10 Thread Dmitry Vasilyev
I have written, what service stopped. This action is repeatable. You can run command 'psql -c "do $$ unpack p,1x8 $$ language plperlu;"' and after this windows service will stop.  On Сб, 2015-10-10 at 10:23 -0500, Tom Lane wrote: > Robert Haas writes: > > On Fri, Oct 9,

Re: [HACKERS] Postgres service stops when I kill client backend on Windows

2015-10-10 Thread Dmitry Vasilyev
Hello Tom! On Сб, 2015-10-10 at 10:55 -0500, Tom Lane wrote: > Dmitry Vasilyev writes: > > I have written, what service stopped. This action is repeatable. > > You can run command 'psql -c "do $$ unpack p,1x8 $$ language > > plperlu;"' > > and after this windows

Re: [HACKERS] Postgres service stops when I kill client backend on Windows

2015-10-10 Thread Pavel Stehule
2015-10-10 18:04 GMT+02:00 Dmitry Vasilyev : > Hello Tom! > > On Сб, 2015-10-10 at 10:55 -0500, Tom Lane wrote: > > Dmitry Vasilyev writes: > > > I have written, what service stopped. This action is repeatable. > > > You can run command 'psql

Re: [HACKERS] Postgres service stops when I kill client backend on Windows

2015-10-10 Thread Tom Lane
Dmitry Vasilyev writes: > On Сб, 2015-10-10 at 10:55 -0500, Tom Lane wrote: >> and (b) you still haven't convinced me that you had an actual service >> stop, and not just that the recovery time was longer than psql would >> wait before retrying the connection. > The

Re: [HACKERS] Postgres service stops when I kill client backend on Windows

2015-10-10 Thread Ali Akbar
Greetings, 2015-10-11 0:18 GMT+07:00 Pavel Stehule : > > 2015-10-10 18:04 GMT+02:00 Dmitry Vasilyev : > >> >> On Сб, 2015-10-10 at 10:55 -0500, Tom Lane wrote: >> > Dmitry Vasilyev writes: >> > > I have written, what

Re: [HACKERS] Postgres service stops when I kill client backend on Windows

2015-10-10 Thread Michael Paquier
On Sun, Oct 11, 2015 at 8:54 AM, Ali Akbar wrote: > C:\Windows\system32>taskkill /F /PID 2080 > SUCCESS: The process with PID 2080 has been terminated. taskkill /f *forcefully* terminates the process targeted [1]. Isn't that equivalent to a kill -9? If you headshot a backend

Re: [HACKERS] Postgres service stops when I kill client backend on Windows

2015-10-09 Thread Charles Clavadetscher
Hello Dmitry > -Original Message- > From: pgsql-hackers-ow...@postgresql.org > [mailto:pgsql-hackers-ow...@postgresql.org] On Behalf Of Dmitry Vasilyev > Sent: Freitag, 9. Oktober 2015 11:52 > To: pgsql-hackers@postgresql.org > Subject: [HACKERS] Postgres service stops when I kill client

Re: [HACKERS] Postgres service stops when I kill client backend on Windows

2015-10-09 Thread Robert Haas
On Fri, Oct 9, 2015 at 5:52 AM, Dmitry Vasilyev wrote: > I’ve started PostgreSQL server on Windows and then I kill client > backend’s process by taskkill the service was stopped: > > postgres=# select pg_backend_pid(); > pg_backend_pid > >

Re: [HACKERS] Postgres service stops when I kill client backend on Windows

2015-10-09 Thread Dmitry Vasilyev
This code stoped server too: postgres=# do $$ unpack p,1x8 $$ language plperlu; server closed the connection unexpectedly This probably means the server terminated abnormally before or while processing the request. The connection to the server was lost. Attempting reset: Failed.