In our Shopify Dec 8 allowed_sources & Jan 1, 2027 expiring offline token guide , a sharp question came up in the comments right away:
How does pg_advisory_xact_lock actually behave behind **PgBouncer in transaction pooling mode , and when should you use **Redis SET NX PX + Lua * instead?*
When Shopify's 60-minute expiring offline tokens roll over during a merchant flash sale (10–50 concurrent orders/create and inventory_levels/update webhooks hitting your app at the same millisecond), picking the wrong locking primitive either causes 401 OAuth token rotation storms or exhausts your Postgres connection pool .
Here is the exact breakdown of all three patterns in production.
1.…