Database Timeout only in some scenarios

Hi guys. I have an user trying to perform an action in bulk for 3000 images but we get a database timeout every single time. The strange thing is that I'm using the exact same settings but on a 7000 images task and it works normally. I'm happy to provide all the context and information needed for it but I honestly don't know what could be happening. We thought it was the number of images but then we tried with more than double and it's ok.
No description
No description
23 Replies
Chocci_Milk
Chocci_Milk6mo ago
What table is this happening on? Could you please share a traceId?
Rena
RenaOP6mo ago
6e65691d09ec0dd6ad1ca3953aec0f3c 6e65691d09ec0dd6ad1ca3953aec0f3c
Chocci_Milk
Chocci_Milk6mo ago
Ok, I've just run an operation on your db table. Let me know if this persists
Rena
RenaOP6mo ago
Yes it persists The store with issues is https://admin.shopify.com/store/pilgrim-b2c
Chocci_Milk
Chocci_Milk6mo ago
The store doesn't matter in this particular case. You're having database operation timeouts, unrelated to the shop that's experiencing them
Rena
RenaOP6mo ago
I see Why does it happen there specifically and not in a reqiest twice as big?
Chocci_Milk
Chocci_Milk6mo ago
I need to investigate further Are you perhaps passing a very large filter to fetch media records?
Chocci_Milk
Chocci_Milk6mo ago
This is probably what's causing the issues:
No description
Chocci_Milk
Chocci_Milk6mo ago
If you pass too many filters you can have quite slow queries
Rena
RenaOP6mo ago
When I do an all images bulk ids is empty So in the request that breaks, that array comes empty and it skips that
Chocci_Milk
Chocci_Milk6mo ago
From the traceId that you shared, I see a filter for ids in an array of 51 items Still digging btw
Rena
RenaOP6mo ago
091b5afd68e8ec59bab267b6b382e2c3 recent one
Chocci_Milk
Chocci_Milk6mo ago
Still a ton of ids in that query
Rena
RenaOP6mo ago
Yeah. Sorry I don't usually work on this app that's Renan and he is on vacation haha Trying to put this fire out I think I can't skip that id filter
Chocci_Milk
Chocci_Milk6mo ago
I was wrong about the number of id filters Its way more Ok, to fix this issue you need to change the way that you folks make requests to the database. You seem to be filtering on over 1700 ids. You need to split the filters into smaller chunks.
Rena
RenaOP6mo ago
It's like 3 k, right?
Chocci_Milk
Chocci_Milk6mo ago
You should have a filter array of around 100 ids at a time
Rena
RenaOP6mo ago
How can I do that?
Chocci_Milk
Chocci_Milk6mo ago
Split the ids array into chunks, use a for loop to loop through chunks use a while loop inside the for to fetch all data you need and add it to the overall returned records array
Rena
RenaOP6mo ago
Everything inside bulkGenerateProducts, correct?
Chocci_Milk
Chocci_Milk6mo ago
I would do that in general for all your helper functions because the same filtering is done in all of them
Rena
RenaOP6mo ago
I see. Thank you
Chocci_Milk
Chocci_Milk6mo ago
No problem! Let us know if you need more information

Did you find this page helpful?