Re: PostgreSQL stops when adding a breakpoint in CLion

From: Stanislav Bashkyrtsev <stanislav(dot)bashkirtsev(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Tomas Vondra <tomas(dot)vondra(at)enterprisedb(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: PostgreSQL stops when adding a breakpoint in CLion
Date: 2022-01-04 08:26:28
Message-ID: CAMtnYL_s_L1Zd7h-vpGWFDJowZEuaBPBpwU+HDG8-1KzD4atAA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> In a standalone backend, I think there are only 3 ways to get to
> normal shutdown:
> * SIGTERM
> * SIGQUIT
> * EOF on stdin

I debugged a bit more and I see that getc() returns with -1 in
interactive_getc() which is interpreted as EOF:
c = getc(stdin);

I see that errno == EINTR when it happens. This is as much as I can figure
out in C, so I'm leaving it at that. Your advice about debugging the
backend process ("select pg_backend_pid()") instead of running in a
single-user mode worked for me, thank you!

On Tue, Jan 4, 2022 at 1:02 AM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:

> Stanislav Bashkyrtsev <stanislav(dot)bashkirtsev(at)gmail(dot)com> writes:
> >> Why do you think postgres quits?
>
> > The process was running and then it stopped. And in the console I see:
> > 2022-01-03 23:23:29.495 MSK [76717] LOG: checkpoint starting: shutdown
> > immediate
>
> In a standalone backend, I think there are only 3 ways to get to
> normal shutdown:
> * SIGTERM
> * SIGQUIT
> * EOF on stdin
>
> It's not very clear which of those your setup is triggering.
>
> In any case, debugging standalone mode is very very rarely
> what you should be doing; it's only vaguely related to normal
> operation, plus you lack all the creature comforts of psql.
> The usual thing is to start a normal interactive session, find out
> the PID of its connected backend process ("select pg_backend_pid()"
> is a reliable way), and then attach to that process with GDB or your
> debugger of choice.
>
> regards, tom lane
>

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Himanshu Upadhyaya 2022-01-04 09:18:33 Re: SQL/JSON: functions
Previous Message Alexander Lakhin 2022-01-04 08:00:00 Re: Proposal: remove obsolete hot-standby testing infrastructure