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

Running two different queries concurrently with Promise.all returns the same results #73

Closed
tomanagle opened this issue Dec 16, 2021 · 9 comments · Fixed by #74
Closed

Comments

@tomanagle
Copy link

We upgraded from ^6.0.4 to ^7.1.2 and noticed some really weird results when running queries concurrently with Promise.all.

The queries were returning the same results, sometimes from query A and sometimes from query B. We would get different execution ids and use those to make the query, but the results were the same.

Let me know if you need a code sample to explain it better.

@ghdna
Copy link
Owner

ghdna commented Dec 27, 2021

yes, please provide sample code. And are you saying the issue didn't exist on previous version

@piyushk96
Copy link
Contributor

Problem for me too. I'm getting same results for multiple SELECT queries that are running concurrently. @ghdna just put 10-15 unique select queries inside Promise.all and you will get the same results for all the queries.

@tomanagle
Copy link
Author

Yeah, we rolled back to ^6.0.4 and it works perfectly now.

As for testing it, no need for 15 select queries, we just had 2.

@ghdna
Copy link
Owner

ghdna commented Jan 11, 2022

That's good context for me to check what's going on between the 2 versions. Thanks. Will look into this.

@piyushk96
Copy link
Contributor

Just to mention Somentimes I'm also getting following error when running queries concurrently

{
    "type": "Error",
    "message": "Query has not yet finished. Current state: QUEUED",
    "stack":
        InvalidRequestException: Query has not yet finished. Current state: QUEUED
            at Request.extractError (/home/ec2-user/sapphire-pm2/source/node_modules/aws-sdk/lib/protocol/json.js:52:27)
            at Request.callListeners (/home/ec2-user/sapphire-pm2/source/node_modules/aws-sdk/lib/sequential_executor.js:106:20)
            at Request.emit (/home/ec2-user/sapphire-pm2/source/node_modules/aws-sdk/lib/sequential_executor.js:78:10)
            at Request.emit (/home/ec2-user/sapphire-pm2/source/node_modules/aws-sdk/lib/request.js:688:14)
            at Request.transition (/home/ec2-user/sapphire-pm2/source/node_modules/aws-sdk/lib/request.js:22:10)
            at AcceptorStateMachine.runTo (/home/ec2-user/sapphire-pm2/source/node_modules/aws-sdk/lib/state_machine.js:14:12)
            at /home/ec2-user/sapphire-pm2/source/node_modules/aws-sdk/lib/state_machine.js:26:10
            at Request.<anonymous> (/home/ec2-user/sapphire-pm2/source/node_modules/aws-sdk/lib/request.js:38:9)
            at Request.<anonymous> (/home/ec2-user/sapphire-pm2/source/node_modules/aws-sdk/lib/request.js:690:12)
            at Request.callListeners (/home/ec2-user/sapphire-pm2/source/node_modules/aws-sdk/lib/sequential_executor.js:116:18)
            at Request.emit (/home/ec2-user/sapphire-pm2/source/node_modules/aws-sdk/lib/sequential_executor.js:78:10)
            at Request.emit (/home/ec2-user/sapphire-pm2/source/node_modules/aws-sdk/lib/request.js:688:14)
            at Request.transition (/home/ec2-user/sapphire-pm2/source/node_modules/aws-sdk/lib/request.js:22:10)
            at AcceptorStateMachine.runTo (/home/ec2-user/sapphire-pm2/source/node_modules/aws-sdk/lib/state_machine.js:14:12)
            at /home/ec2-user/sapphire-pm2/source/node_modules/aws-sdk/lib/state_machine.js:26:10
            at Request.<anonymous> (/home/ec2-user/sapphire-pm2/source/node_modules/aws-sdk/lib/request.js:38:9)
            at Request.<anonymous> (/home/ec2-user/sapphire-pm2/source/node_modules/aws-sdk/lib/request.js:690:12)
            at Request.callListeners (/home/ec2-user/sapphire-pm2/source/node_modules/aws-sdk/lib/sequential_executor.js:116:18)
            at callNextListener (/home/ec2-user/sapphire-pm2/source/node_modules/aws-sdk/lib/sequential_executor.js:96:12)
            at IncomingMessage.onEnd (/home/ec2-user/sapphire-pm2/source/node_modules/aws-sdk/lib/event_listeners.js:313:13)
            at IncomingMessage.emit (events.js:327:22)
            at IncomingMessage.EventEmitter.emit (domain.js:467:12)
            at endReadableNT (internal/streams/readable.js:1327:12)
            at processTicksAndRejections (internal/process/task_queues.js:80:21)
    "code": "InvalidRequestException",
    "time": "2022-01-11T13:27:54.215Z",
    "requestId": "9acfd970-bc05-42d8-8e1b-4b318e1ee6ce",
    "statusCode": 400,
    "retryable": false,
    "retryDelay": 66.02900664883433
}

According to my understanding since all concurrent queries are returning same QueryExecutionId when one of them gets finished other may be in RUNNING or QUEUED state and when it tries to get results for queued or running query it throws this unhandled promise rejection

@piyushk96
Copy link
Contributor

@ghdna I have opened a PR for the fix. Please check.

@IagorSs
Copy link

IagorSs commented Jan 14, 2022

Same problem here, please accept this PR 😭

@filipemarruda
Copy link

Same here! +1

@ghdna ghdna closed this as completed in #74 Jan 17, 2022
@ghdna
Copy link
Owner

ghdna commented Jan 17, 2022

Merged. Thanks for sharing the issue and submitting the PR.

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

Successfully merging a pull request may close this issue.

5 participants