dj-stripe / dj-stripe

dj-stripe automatically syncs your Stripe Data to your local database as pre-implemented Django Models allowing you to use the Django ORM, in your code, to work with the data making it easier and faster.
https://dj-stripe.dev
MIT License
1.56k stars 474 forks source link

dj-stripe adds unwanted connections to db to query djstripe_webhookendpoint that blocks use of django-extensions commands like reset_db #2005

Open duaneking opened 6 months ago

duaneking commented 6 months ago

Describe the bug I'm starting a new app using dj-stripe and I'm noticing that any attempted use of the django-extenton reset_db command fails locally due to what I have tracked down as an extra unwanted connection that seems to be spun up by dj-stripe to do a SQL query for the api endpoints based on dj-stripe as sort of a prelude, that is unwanted and actively breaks things.

To be clear, it should NOT be making this query for endpoint data, but here is the psql output that shows its connecting to my dev db even if I don't want it to as it should not be doing anything like this, it should not be touching the db at all for this operation, as that blocks the dropping of the database and does not allow us to reset it for dev work locally but also creates HUGE issues for production deployments.

16398 | gdc_dev | 30948 | | 10 | postgres | | ::1 | | 50153 | 2023-11-02 19:04:21.528199-07 | | 2023-11-02 19:04:21.703432-07 | 2023-11-02 19:04:21.703629-07 | Client | ClientRead | idle | | | | SELECT "djstripe_webhookendpoint"."djstripe_created", "djstripe_webhookendpoint"."djstripe_updated", "djstripe_webhookendpoint"."djstripe_id", "djstripe_webhookendpoint"."id", "djstripe_webhookendpoint"."djstripe_owner_account_id", "djstripe_webhookendpoint"."livemode", "djstripe_webhookendpoint"."created", "djstripe_webhookendpoint"."metadata", "djstripe_webhookendpoint"."description", "djstripe_webhookendpoint"."api_version", "djstripe_webhookendpoint"."enabled_events", "djstripe_webhookendpoint"."secret", "djstripe_webhookendpoint"."status", "djstripe_webhookendpoint"."url", "djstripe_webhookendpoint"."application", "djstripe_webhookendpoint"."djstripe_uuid", "djstripe_webhookendpoint"."tolerance" FROM "djstripe_webhookendpoint" | client backend

I dont want these queries to happen, they are blocking my ability to get work done because they are blocking my ability to use the reset_db command, actively interfering with common dev tools that I depend on. How do I turn them off until this is fixed?

To Reproduce Install a new django 4.2 app, add dj-stripe, add and configure django-allauth if you want everything I have locally, and add dj-extensions, then then do a bad deployment and need to reset your db by using the django-extention reset_db command. It will fail, citing unwanted extra connections in the same table, even if you reset your server and try again, because the dj-stripe query is connecting even when it should not be, and making the db fall over by blocking the 'reset_db' command.

Software versions