| 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)
SELECT pid |
FROM pg_stat_activity |
WHERE datname='<puppetdb/pe-puppetdb>' |
AND usename='<puppetdb data role>';
|
For each pid returned by the above query call either
SELECT pg_cancel_backend( <pid> );
|
or
SELECT pg_terminate_backend( <pid> );
|
|