Replies: 1 comment
-
I have this error randomly in my app on production. In my case I use directly lambdas in AWS and I can't downgrade nodejs (and it's not recommanded, v12 is not supported by node team) My server is never full of connection so, I don't understand why. This is my configuration : db = knex({
client: KnexMysql2,
connection: {
host: config.rds.host,
port: config.rds.port,
user: config.rds.user,
password: config.rds.password,
database: config.rds.database,
multipleStatements: true,
decimalNumbers: true,
timezone: '+00:00',
/* istanbul ignore next -- @preserve */
typeCast(field: { type: string; length: number; string: () => string }, next: () => void) {
// used to convert TINYINT to boolean
if (field.type === 'TINY' && field.length <= 4) {
return field.string() === '1';
}
return next();
},
},
// I have to do this to not have any problems with lambdas invocations
pool: {
min: 0,
max: params?.pool?.max || 1,
},
});
Model.knex(db); My connection is start with launch of lambda and close after. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have my backend hosted at Amazon Linux AMI I made some 6 months ago. Much before that, I was using Node 17.x, which I used without much thinking.
As I kept observing - Every DB query invocation (SELECTs included) after a long time resulted in the knex time out error:
Knex: Timeout acquiring a connection. The pool is probably full. Are you missing a .transacting(trx) call?
Now this is a well-known problem and people have tried fixing it either fixing Objection / Knex version or by tweaking their node version.
I tried the former, but did not succeed. I nontheless upgraded to:
Finally, I succeeded by downgrading to Node v12.22.12 (Erbium) through NVM.
The process was not without its fair share of warnings emanating from Objection and Knex.
I don't see any problems with this older Node version so far.
However, I am worried if this is a good approach in the long term, and if there is any knex / Objection config tweak I am discarding without trying.
My prod config is simple (nothing well thought-out, suggestions openly welcome!)
In a nutshell:
Should I make a new Amazon VM Image with Node 12.2 to make it stick, or should I try any knex config changes to see if they work with latest Node version?
Note: AWS Linux that I use currently prevents me from upgrading Node through NVM beyond 17.x for some reason - so upgrading Node isn't an option - unless I am missing any obvious solution there.
I am going live with this in 5 days, so any help will be highly appreciated!
Beta Was this translation helpful? Give feedback.
All reactions