Skip to content

execute_sql hangs forever until you call .rows on the results #163

@grcooper

Description

@grcooper

Problem

When calling execute_sql the program hangs forever (I had to kill -9 it) unless you read from .rows.

Environment details

  • OS: MacOS
  • Ruby version: 3.4.2
  • Gem name and version: google-cloud-spanner 2.26

Steps to reproduce

  1. Create a client
  2. client.execute_sql
  3. Never read the result from execute_sql
  4. Program hangs forever

Code example

require "google/cloud/spanner"

puts "Starting"
emulator_host = ENV.fetch("SPANNER_EMULATOR_HOST", nil)
project_id = ENV.fetch("SPANNER_EMULATOR_PROJECT", "")
instance_id = ENV.fetch("SPANNER_EMULATOR_INSTANCE", "")
database_id = ENV.fetch("SPANNER_EMULATOR_DATABASE", "")

puts "Creating project"
project = Google::Cloud::Spanner.new(
  project_id: project_id,
  emulator_host: emulator_host,
)

puts "Creating client"
client = project.client(instance_id, database_id)

puts "Executing sql"
puts client.execute_sql("SELECT * FROM my_table")

Change the last line to:

puts client.execute_sql("SELECT * FROM my_table").rows.first

And it will no longer hang.

Full backtrace

There is no backtrace, the program just hangs forever after printing "Executing sql"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions