unicorn Ruby/Rack server user+dev discussion/patches/pulls/bugs/help
 help / color / mirror / code / Atom feed
From: Sam Saffron <sam.saffron@gmail.com>
To: mongrel-unicorn@rubyforge.org
Subject: unblock function in pg messes up with unicorn
Date: Fri, 6 Dec 2013 23:29:38 +1100	[thread overview]
Message-ID: <CAAtdryPgc3N6N6kTJaNpYJb5VNvdtROd+37Pc3Z4PQUBssc39g@mail.gmail.com> (raw)

require 'pg'

conn = PG.connect(dbname: 'meta')

trap 'USR1' do
  puts "YAY"
end

Thread.new do
  sleep 0.1
  Process.kill("USR1", Process.pid)
end

sleep 1

puts "HERE"

Thread.new do
  sleep 0.1
  Process.kill("USR1", Process.pid)
end

conn.exec("select pg_sleep(10)")

sam@ubuntu:~/Source$ ruby test2.rb
YAY
HERE
YAY
test2.rb:27:in `exec': ERROR:  canceling statement due to user request
(PG::QueryCanceled)
from test2.rb:27:in `<main>'


this is the ubf defined inside pg.

 void ubf_cancel_running_command(void *c)
 {
   /*
       has no idea why it was interrupted, should it stop the query due to USR1
   */
   PGconn *conn = (PGconn*) c;
   PQrequestCancel(conn);
 }


This leaves a bunch of questions:

1. Is this a pg bug? How could they even implement a ubf in such a way
that it does not stop queries when signals are sent? The main issue is
that without this Thread.kill will have to wait for queries to finish.

2. Is this a ruby bug? should there be a more sophisticated protocol
here? Should trap handlers inform the runtime that a ubf is not
needed?

something else ?

Similar issue exists in mysql afaik.
_______________________________________________
Unicorn mailing list - mongrel-unicorn@rubyforge.org
http://rubyforge.org/mailman/listinfo/mongrel-unicorn
Do not quote signatures (like this one) or top post when replying

             reply	other threads:[~2013-12-06 12:37 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-06 12:29 Sam Saffron [this message]
2013-12-06 18:48 ` unblock function in pg messes up with unicorn Eric Wong
2013-12-07  0:04   ` Sam Saffron

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://yhbt.net/unicorn/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAAtdryPgc3N6N6kTJaNpYJb5VNvdtROd+37Pc3Z4PQUBssc39g@mail.gmail.com \
    --to=sam.saffron@gmail.com \
    --cc=mongrel-unicorn@rubyforge.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhbt.net/unicorn.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).