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

Query was empty error on Preview 16 #902

Closed
iRoachie opened this issue Nov 8, 2019 · 22 comments
Closed

Query was empty error on Preview 16 #902

iRoachie opened this issue Nov 8, 2019 · 22 comments
Assignees
Labels
bug/2-confirmed Bug has been reproduced and confirmed. kind/bug A reported bug.
Milestone

Comments

@iRoachie
Copy link

iRoachie commented Nov 8, 2019

I recently updated my project to use preview016 which released today. However, intermittently there are errors being thrown.

More exactly:

Error in connector: Error querying the database: Server error: `ERROR 42000 (1065): Query was empty'

I'd run a query (works), wait for couple seconds, and then re-run the same exact query, and the error would throw.

The only thing that works is to downgrade back to preview015.

@pantharshit00
Copy link
Contributor

Can you please tell me how to reproduce this?

I think this might be a regression from this PR: #841

@pantharshit00 pantharshit00 added bug/0-unknown Bug is new, does not have information for reproduction or reproduction could not be confirmed. kind/bug A reported bug. labels Nov 8, 2019
@iRoachie
Copy link
Author

iRoachie commented Nov 8, 2019

It seems like a time issue and it happens intermittently. All I can do is provide a screen recording. https://www.loom.com/share/a42393267be34b6eb658460d2d05f4cc

In the video, you can see it fails just after more than 20-25 secs ellipse between requests. Nothing changed with the query or anything.

@iRoachie
Copy link
Author

iRoachie commented Nov 8, 2019

This happens in preview16.1 as well

@iRoachie
Copy link
Author

iRoachie commented Nov 8, 2019

It just fails after being idle 🤷🏽‍♂️

@krskoondra
Copy link

The same issue. I can provide error log from the server:

Invalid `return photon[mappedField.photonAccessor][mappedField.operation]()` invocation in /home/ondrej/gitlab/topic-admin/node_modules/nexus-prisma/dist/builder.js:128:97

  124 const gqlFieldName = resolvedConfig.alias || mappedField.field.name;
  125 t.field(gqlFieldName, Object.assign(Object.assign({ type: this.publisher.outputType(resolvedConfig.type, mappedField.field) }, dmmfListFieldTypeToNexus(mappedField.field.outputType)), { args: this.buildArgsFromField(typeName, mappedField.operation, mappedField.field, resolvedConfig), resolve: (_parent,[object Object], args,[object Object], ctx) => {
  126         const photon = this.getPhoton(ctx);
  127         utils_1.assertPhotonInContext(photon);
→ 128         return photon[mappedField.photonAccessor][mappedField.operation](args)

Reason: Error in connector: Error querying the database: Server error: `ERROR 42000 (1065): Query was empty'

    at errorResolver (/home/ondrej/gitlab/topic-admin/build/server/server.js:1028:15)
    at process._tickCallback (internal/process/next_tick.js:68:7)

Version: prisma2@2.0.0-preview016.1

@pantharshit00
Copy link
Contributor

I am unable to reproduce this. I used the GraphQL starter. Can anyone share your code so that I can try with that once?

@iRoachie
Copy link
Author

iRoachie commented Nov 11, 2019

@pantharshit00 Here ya go - https://github.com/iRoachie/another-prisma2-bug

Starter Project again. Nothing changed.

@pantharshit00
Copy link
Contributor

pantharshit00 commented Nov 12, 2019

image

I can reproduce this now. Seems only reproducible in with the MySQL connector, not with the Postgres or SQLite connector.

Thanks again for sharing the reproduction with us :)

Internal note:
Use the above repository for the reproduction. Fill in your MySQL credentials in the schema file and run the server. Query it once and then wait for 45 seconds and query again to reproduce. Video shared by @iRoachie is helpful here(https://loom.com/share/a42393267be34b6eb658460d2d05f4cc).

@pantharshit00 pantharshit00 added bug/2-confirmed Bug has been reproduced and confirmed. process/candidate and removed bug/0-unknown Bug is new, does not have information for reproduction or reproduction could not be confirmed. labels Nov 12, 2019
@mavilein mavilein added this to the Preview 17 milestone Nov 12, 2019
@pimeys
Copy link
Contributor

pimeys commented Nov 12, 2019

Found the bug, fixing today. The problematic method is this, but I'm just rewriting the pooling and now all connections test their status with SELECT 1 instead of an empty query.

https://github.com/prisma/quaint/blob/master/src/pool/mysql.rs#L39-L44

@pimeys
Copy link
Contributor

pimeys commented Nov 12, 2019

Going to be merged to prisma engines tomorrow, the quaint changes are here prisma/quaint#30

https://github.com/prisma/quaint/pull/30/files#diff-b4aea3e418ccdb71239b96952d9cddb6R351-R355

@pimeys
Copy link
Contributor

pimeys commented Nov 13, 2019

Fix should be in the next release on Thursday (or if compiling the core from sources).

@himerus
Copy link

himerus commented Nov 22, 2019

I'm still seeing this error on prisma2@2.0.0-alpha.351. I've been seeing this for a couple weeks now, and was hoping Preview 17 would resolve it. Based on the slack notification today, I decided to hit the alpha build to see if my problems went away, and it worked well for a short bit it seemed, then this repeatedly is thrown.

Error:
Invalid `photon.()` invocation in /var/www/apps/api/node_modules/nexus-prisma/src/builder.ts:236:18

Reason: Error in connector: Error querying the database: Server error: `ERROR 42000 (1065): Query was empty'

    at PhotonFetcher.<anonymous> (/var/www/apps/api/node_modules/@generated/photon/index.js:54:27)
    at Generator.throw (<anonymous>)
    at rejected (/var/www/apps/api/node_modules/@generated/photon/index.js:6:65)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)

@pimeys
Copy link
Contributor

pimeys commented Nov 23, 2019

The preview 17 was delayed to next Monday. I still needed to test this with the latest master, which I've been using together with MySQL for benchmarking the whole week without seeing this issue. Now I've been running the latest query engine for over ten minutes and the connections are still up with no errors.

Logs after being idle for a while and then querying:

Nov 23 12:47:41.959 INFO quaint::connector::metrics: query: "SELECT 1", params: [] (in 1ms)    
Nov 23 12:47:41.959 INFO quaint::connector::metrics: query: "SELECT `prisma`.`Artist`.`ArtistId` FROM `prisma`.`Artist` WHERE `prisma`.`Artist`.`ArtistId` = ? ORDER BY `prisma`.`Artist`.`ArtistId` ASC LIMIT ? OFFSET ?", params: [55,1,0] (in 0ms)    

Where we can see the first query checking the connection status after being idle for a while, which used to be the empty query (which btw. works for psql/sqlite), but is now a SELECT 1.

You can try to find the Prisma binary from your node modules, and see the version:

> ./target/release/prisma --version
b8d90fea39d266b128b4d748db5aca8505bb1026

The currently available preview 16.2 is not including the fix yet.

@himerus
Copy link

himerus commented Nov 23, 2019

I realize that Preview 16.2 doesn't include the fix, as I've been using that for the last two weeks. I'm using prisma2@2.0.0-alpha.351 as instructed in the Slack post on Friday about waiting until Monday to push the next version. This was an attempt to test the latest.

I'll do additional verification/testing as I can over the weekend, as well as after the official release is made on Monday before starting a new issue.

@pimeys
Copy link
Contributor

pimeys commented Nov 24, 2019

It would still be useful if you'd give me the exact commit id from the prisma binary, so I'd know in which commit you're currently. You should get it with the --version parameter.

@pimeys
Copy link
Contributor

pimeys commented Nov 24, 2019

Ok, tried it with the binary distributed through npm, so sudo npm install -g --unsafe-perm prisma2@alpha.

In /usr/lib/node_modules/prisma2 I have query-engine-debian-openssl-1.1.x binary.

> ./query-engine-debian-openssl-1.1.x --version
b8d90fea39d266b128b4d748db5aca8505bb1026

Been running this binary for 30 minutes against a MySQL database with no errors.

Maybe you could try to uninstall prisma2 and then install the latest alpha from scratch. Might be some old npm version somewhere you're using instead of the latest.

@himerus
Copy link

himerus commented Nov 24, 2019

prisma2 version:

prisma2@2.0.0-alpha.351, binary version: b8d90fea39d266b128b4d748db5aca8505bb1026

Seems to line up with yours. I'm running all this containerized, and have setup scripts to grab all related dependencies for global npm packages (including prisma2) as well as deps for API backend and UI.

I've reset on many occasions with a full nuke script which wipes any node_modules in my project apps as well as resets the container so all global packages need reinstalled (even nvm).

Just tested again, and it took me about 5 clicks around and attempts to hit the API before I got the error again.

@pantharshit00
Copy link
Contributor

pantharshit00 commented Nov 25, 2019

Hi @himerus,

Can you please make sure that you ran prisma2 dev after you have updated the cli? Photon will use the binary situated in the local context which might be outdated if you have not prisma2 dev after updating your cli.

To make sure run the this:

./node_modules/@prisma/photon/runtime/query-engine-darwin --version

(if you are on a different OS than Mac, change the binary name accordingly)

and it should match the following hash:
image

You might also need to update your project to utilize the new photon facade if you haven't done that already: prisma/prisma-client-js#261. To do that, run npm install @prisma/photon@alpha and change import path for Photon from @generated/photon to @prisma/photon.

I was also unable to reproduce this now.

@Constans
Copy link

Do you know if preview017 is scheduled for today, or for next Monday? I have the same issue with the findOne query and I want to know if I switch to the alpha version or wait for the preview one.
Thanks!

@pimeys
Copy link
Contributor

pimeys commented Nov 25, 2019

It should be coming out today. Was postponed from last Thursday due to some last minute fixes and not having enough time.

@himerus
Copy link

himerus commented Nov 25, 2019

@pantharshit00 @pimeys Thanks for the help on this one.

My report was 'correct', but it was caused because I was trying to use a global install of the Primsa CLI. So I had one (global) bumped to latest, but not the internal package in node_modules for my API.

So I was on an odd edge case.

I've managed to get everything updated today with the latest from Preview 17, including a couple hiccups with pinned dependencies on nexus and nexus-prisma. Once got past all that, it appears to be smooth sailing now.

@pimeys
Copy link
Contributor

pimeys commented Nov 25, 2019

Good that it's settled for you. Happy hacking :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug/2-confirmed Bug has been reproduced and confirmed. kind/bug A reported bug.
Projects
None yet
Development

No branches or pull requests

8 participants