When the puppetdb migrator is performing a migration it needs to ensure the data role is not connected to the database.
The new migration workflow should look like * Begin a transaction, * Lock the migration table with {{access exclusive}} * Check to see if migrations are needed, and if so, * Revoke connection access for data role, * Disconnect any in-flight connections * Perform migrations, * Commit transaction, * Reallow access for the data role
To disconnect the data role's database connection(s) {code} SELECT pg_terminate_backend( pid) FROM pg_stat_activity WHERE datname='<puppetdb/pe-puppetdb>' AND usename='<puppetdb data role>'; {code}
For each pid returned by the above query call either {code} SELECT pg_cancel_backend( <pid> ); {code} or {code} SELECT pg_terminate_backend( <pid> ); {code}
When the puppetdb migrator is performing a migration it needs to ensure the data role is not connected to the database.
The new migration workflow should look like *
Begin a transaction, * Lock the schema migration table with {{access exclusive}}
* Check to see if migrations are needed, and if so, * Revoke connection access for data role, * Disconnect any in-flight connections * Perform migrations, * Commit transaction, * Reallow access for the data role
To disconnect the data role's database connection(s) {code} SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE datname='<puppetdb/pe-puppetdb>' AND usename='<puppetdb data role>'; {code}
When the puppetdb migrator is performing a migration it needs to ensure the data role is not connected to the database.
The new migration workflow should look like
* Lock the schema migration table with {{access exclusive}} * Check to see if migrations are needed, and if so, * Revoke connection access for data role, * Disconnect any in-flight connections * Perform migrations, * Commit transaction, * Reallow access for the data role
To disconnect the data role's database connection(s) {code} SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE datname='<puppetdb/pe-puppetdb>'
AND usename!='<puppetdb data migrator role>'; {code}