shayonj / pg_easy_replicate

Easily setup logical replication and switchover to new database with minimal downtime
MIT License
948 stars 18 forks source link

added correct user to stop_sync drop of subscription #183

Closed annadowling closed 1 week ago

annadowling commented 2 weeks ago

During testing of stop_sync I encountered the following error when it tries to drop the subscription:

PG::InsufficientPrivilege: ERROR: must be owner: pg_subscription_zdt_migration_test

I noticed that we specify the user to create the subscription but it was not assuming this user to drop it afterwards causing the above error.

annadowling commented 2 weeks ago

nice! I wonder why didn't the specs catch this

will dig into that and see if I can figure it out.

annadowling commented 2 weeks ago

nice! I wonder why didn't the specs catch this

will dig into that and see if I can figure it out.

In the tests we call setup_tables and in all the components of the database_helpers class used here we use james-bond 🔫 as the user. It looks like the tests are always run in the context of thejames-bond user here, which has sufficient privileges to perform all necessary actions, including creating and dropping subscriptions https://github.com/shayonj/pg_easy_replicate/blob/main/spec/database_helpers.rb#L27 https://github.com/shayonj/pg_easy_replicate/blob/main/spec/pg_easy_replicate/orchestrate_spec.rb#L230:

Will see if I can add some further coverage on this.

shayonj commented 1 week ago

ah! there it is :D (blast from the past) https://github.com/shayonj/pg_easy_replicate/blob/975faae4aa763eb6e9abd0467b5d5ab0e0b223ff/spec/pg_easy_replicate/orchestrate_spec.rb#L747-L748