Session timeout when using pool & parallel for #16146
-
Hi guys, I am using sequelize in my AWS Lambda. I checked out https://sequelize.org/docs/v6/other-topics/aws-lambda/ and it works well -> when I do not do long running transactions. What I mean is the following, I have:
Works when I do, e.g. But when I go for something that takes longer, e.g.
It runs into timeout. If I understand correctly what happens:
So yes, it cannot get a connection in 4 secs, but this is just because all available connections are in use and not because the DB is not answering. What to do about it? Currently I put acquire as high as I know the longest transaction runs. But this is especially bad, if my DB is not available... I would prefer, if I could distinguish "wait for connection" or "wait for free connection"...I hope it is clear what I mean. Does sequelize have something like this? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
If you have hundreds of them, have you considered either chunking the data to call upsert in batches of 20, or using your own async queue for this operation? It's not going to improve how fast it goes but it would solve the connection acquire timeout |
Beta Was this translation helpful? Give feedback.
-
Hi ephys, thanks for the quick reply. Yeah your idea is something that can be done and maybe we need to introduce it. But I had hoped that sequelize could distinguish between "waiting to establish connection" & "waiting to get a connection from the (exhausted) pool"...because I think these are two different topics. So there is nothing that I could use to prevent this (except paying attention that I throttle the request according to the pool size)? |
Beta Was this translation helpful? Give feedback.
It does have both timeouts:
pool.acquire
option is used to configure the timeout used when acquiring a connection from the pooldialectOptions
option to configure the connector library, like below:Each dialect uses different options
If you let me know which connector library you are using, I can look up what the configuration should lo…