hasura / hasura-cloud-preview-apps

MIT License
22 stars 10 forks source link

Handle revoking connections better when tearing down an environment #172

Open cbsmith402 opened 1 year ago

cbsmith402 commented 1 year ago

This seems to be a longstanding issue (see https://github.com/hasura/hasura-cloud-preview-apps/issues/90) and I spent a little time triaging it. It seems that the way you were revoking access (by setting the datallowconn to false) isn't completely compatible with how AWS RDS (and possibly others) is set up. This changes the code to use ALTER DATABASE to set the connection limit to 0 which seems to work better. It also does this for both re-creating an environment and deleting one.

I've been using this for about a week in our app and it seems to be working much better this way. Not sure if I did the build/commits the way you want so feel free to just take the relevant change here in postgres.ts.