Shopify_app gem: Database lock pile-ups when Shopify's token endpoint is slow

Hi all,

We use shopify_app with expiring offline tokens. When Shopify’s token endpoint degrades and starts responding in couple seconds instead of miliseconds, our database started backing up.

The reason is the token refresh in refresh_token_if_expired!. It holds a row lock on the shop while it waits for Shopify to answer. While Shopify was slow, every other job for that shop waited on that lock. So did any insert into tables that reference the shop, such as webhook writes or any concurrent jobs for the same shop also stalled.

Has anyone else using the gem seen this when Shopify is degraded? How are you handling it?

Thanks!

I left out the PR link and our fixes.

5 Likes