Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Process hangs in query block if doing rs.read before rs.each #37

Open
samueleaton opened this issue Jan 13, 2017 · 3 comments
Open

Process hangs in query block if doing rs.read before rs.each #37

samueleaton opened this issue Jan 13, 2017 · 3 comments

Comments

@samueleaton
Copy link

(From our chat in gitter.im)

Process stops at a rs.read(String) for minutes without ever continuing (chk 2 will never be printed):

db.query query_str, var1, var2 do |rs|
  puts "chk 1"
  something = rs.read(String)
  puts "chk 2"
end

The following examples work fine:

# using query_one
db.query_one query_str, var1, var2 do |rs|
  something = rs.read(String)
end

# using from_rs via DB.mapping
db.query query_str, var1, var2 do |rs|
  from_rs rs
end

# using rs.each
db.query query_str, var1, var2 do |rs|
  rs.each do
    something = rs.read(String)
  end
end

Although I was not using the API correctly, an exception should be raised.

Using pg driver

@samueleaton samueleaton changed the title Process hangs in query block if reading from rs.read if not using rs.each Process hangs in query block if doing rs.read before rs.each Jan 13, 2017
@RX14
Copy link
Contributor

RX14 commented May 3, 2017

The same happens if you try to rs.read when there isn't another column. Basically unless you do it perfectly, you get hangs instead of exceptions. I spent quite a while debugging this! This might be limited to the PG driver only. @will?

@samueleaton
Copy link
Author

See our conversation in gitter here: https://gitter.im/crystal-lang/crystal/archives/2017/01/13

@samueleaton
Copy link
Author

From our conversion that I posted to, @spalladino said:

Even if it works, please open an issue in crystal-db explaining the situation; if making that check does not incur in a performance penalty, I'd consider adding it to raise an exception rather than just hanging on the socket

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants