-
Notifications
You must be signed in to change notification settings - Fork 376
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
Issue with multiple orm's and closed connections #86
Comments
I'm going to try your example, I've seen people reporting this regarding node-mysql. |
You just tested this with mysql right? |
Oh.. I just saw the same error you posted in postgres.. weird.. |
Gee... stupid bug. It's so stupid you're going to laugh. This is not driver related, it's just cache which is used across drivers. The key to identify a cache item is just the model and id. Since both connections have the same model/id, when you fetch the second one you get the instance cached from the first one (with the first driver - which is then closed). Doing this solves it temporarily: db.define("animal", {
name : String
}, { cache: false }); Do you have a real use case? I was thinking about changing drivers to have an UID for each instance and have the Cache use this for it's keys. |
I had this issue with both mysql and postgres. I extracted the sample above from my app, which uses node-pool, with a pool of ORMs. To make the new pool work, I would have had to build pool management into ORM, which sounded like a lot of work (but I do think this is a worthy endeavour, to be undertaken some day). Driver UIDs sound like a good fix! Edit hahaha... yeah, the bug did make me laugh |
It works fine now :) |
Thanks!! |
Hey,
I've hit a rather confusing issue with multiple database connections:
It seems that despite me making two connections, ORM is referencing the first one inside both
getConnection
calls.Because of this, an error is thrown, along the lines of
Error: This socket is closed.
or the mysql flavour:Error: Cannot enqueue Query after invoking quit.
Am I doing something wrong?
I spent a long time trying to find the cause, but haven't gotten anywhere.
I've even tried having two differently named
getConnection
functions, with one connecting to postgres and the other mysql, but I got the same error.Thanks.
The text was updated successfully, but these errors were encountered: