Forum OpenACS Development: Re: Problem with db_transaction?

Collapse
Posted by Nis Jørgensen on
Sending an OS signal (SIGTERM) to the backend process is HOW psql terminates a query when you press Ctrl-C ...

Doesn't look like it to me. As far as I can read from the source, psql sends a cancellation message to the server in another connection - which then probably sends a SIGTERM to the process.

And you're misreading the doc you cite, the backend isn't actively checking for a termination message, a new backend process is sent a termination message and it in turn bops the query-running process with a SIGTERM signal. Signals are CAUGHT, not POLLED ... all the doc sez is that the backend, while running a query, doesn't POLL to see if a terminate message has been sent but rather responds to a signal (which takes no overhead since the OS takes care of calling the catching function directly when it processes the signal).
I believe you misunderstood my use of the word "termination". I used it in the context of the postgresql protocol document, not OS signals.

As I read the doc:

  • Cancellation of a query happens by the client sending a message on another connection, as described above.
  • Termination of a connection happens either because of an explicit message sent from the client on the connection, OR when the backend discovers that the connection has been terminated by the client. I don't know how the last part happens, but apparently it is NOT happening during query execution, or at least it didn't for a couple of days on my production server.
  • /Nis

    PS: Can we please have the option back to reply to a reply?