Hi all, I'm seeing some odd behavior. I have two l...
# help
p
Hi all, I'm seeing some odd behavior. I have two lambda functions which connect to my MongoDB Atlas instance. I've looked at all the past messages about MongoDB connection re-use between invocations of the same lambda function and believe I have it set up correctly. My code works like this: Lambda Function 1 is connected to an API endpoint and spawns several invocations of Lambda Function 2, which completes some trivial database calls and parsing (~300 ms excluding Mongo connection time) The behavior I'm seeing is that Lambda Function 2 does not re-use any mongo connection on the first invocation (this connection is also taking an abnormally long time (> 10 seconds)) and times out. A minute later, I can see that the invocation is retried automatically and does not re-use the mongo connection and also times out after 10 seconds. Then two minutes, later, the function is retried a third time, which re-uses the mongo connection and completes in 300ms. Any ideas here on what could be going on?
t
Is this for local mode?
p
No these are deployed
t
I've seen something similiar with serverless v2 rds
p
Not sure if this is helpful but here's an example request that just happened
t
Here's a guess: Mongo Atlas for the first connection it seems it needs a while to spin up from 0. The first invocation triggers that process, but sounds like it's timing out before that's ready. Same for second - the previous invocation isn't being reused because it timed out Third one is able to connect because Mongo Atlas is warmed up at this point. But not sure if this is it
p
I'm not sure if this is an SST issue or if I'm spawning too many lambdas simulataneously which somehow might jam up Mongo?
t
If it's deployed, there's probably not much related to SST that can be an issue. This seems like a Mongo Atlas connection management issue but not entirely sure
p
Ok got it.
If a lambda is able to successfully connect to Mongo Atlas and starts executing main logic but then times out, do you know if that would close the Mongo connection?
Or at least disable re-use from invocation from invocation