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

database.run(...) hangs for a few seconds with invalid query #2014

Open
ikenox opened this issue Mar 5, 2024 · 2 comments
Open

database.run(...) hangs for a few seconds with invalid query #2014

ikenox opened this issue Mar 5, 2024 · 2 comments
Assignees
Labels
api: spanner Issues related to the googleapis/nodejs-spanner API. priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@ikenox
Copy link

ikenox commented Mar 5, 2024

database.run(...) hangs for a few seconds when an invalid query is passed.

Environment details

  • OS: M1 Mac
  • Node.js version: 20.7.0
  • npm version: 10.1.0
  • @google-cloud/spanner version: ^7.5.0
  • spanner emulator version: 1.5.13

Steps to reproduce

I created minimum reproducible code: https://github.com/ikenox/nodejs-spanner-example/tree/hangs-with-invalid-query

git clone git@github.com:ikenox/nodejs-spanner-example.git
git checkout hangs-with-invalid-query
pnpm install
gcloud emulators spanner start &
SPANNER_EMULATOR_HOST=localhost:9010 pnpm exec ts-node src/main.ts

main.ts executes the code like below.

  console.time('valid query');
  await database.run('select 1');
  console.timeEnd('valid query');

  console.time('invalid query');
  try{
    await database.run('select aaa');
  }catch(e){
    console.log(e);
  }
  console.timeEnd('invalid query');

And the output is below:

valid query: 21.579ms
3 INVALID_ARGUMENT: Unrecognized name: aaa [at 1:8]
select aaa
       ^
invalid query: 7.406s
@ikenox ikenox added priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. labels Mar 5, 2024
@product-auto-label product-auto-label bot added the api: spanner Issues related to the googleapis/nodejs-spanner API. label Mar 5, 2024
@surbhigarg92 surbhigarg92 self-assigned this Mar 6, 2024
@surbhigarg92
Copy link
Contributor

@ikenox I verified this , I am able to reproduce this issue with Emulator. But when I using Spanner database directly the command is not hanging.

@flovouin
Copy link

This is probably related to #1444.
I still get those unwanted retries when I (accidentally) write an invalid query and run tests. Not the end of the world as those invalid queries are fixed right away and this never happens in production. However it makes debugging quite frustrating as the retry mechanism takes longer than the default timeout for tests (e.g. in Jest).
I don't understand why this is happening, as the emulator does return the correct statuses, which shouldn't be retried.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: spanner Issues related to the googleapis/nodejs-spanner API. priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

No branches or pull requests

3 participants