Skip to content

Commit

Permalink
Merge pull request #3831 from jpartlow/pe-36120-do-not-kill-connectio…
Browse files Browse the repository at this point in the history
…ns-when-no-migrations-pending

(PE-36120) Do not kill connections when no migrations pending
  • Loading branch information
austb authored Jun 29, 2023
2 parents bcbe0b9 + 7ef9852 commit f768ede
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions src/puppetlabs/puppetdb/scf/migrate.clj
Original file line number Diff line number Diff line change
Expand Up @@ -2555,8 +2555,8 @@
(if-not user
(do
(log/info
(trs "Disconnecting all {0} connections to {1} database before migrating"
user db-name))
(trs "Disconnecting all non-migrator connections to {0} database before migrating"
db-name))
(doseq [user users]
;; Because the revoke may not actually produce an error when
;; it doesn't work.
Expand Down Expand Up @@ -2617,16 +2617,17 @@
tables))]
(if-not write-user
(migrate)
(call-with-connections-blocked-during-migration
db-name
(distinct [read-user write-user])
(fn []
;; So new tables, etc. are owned by the write-user
(jdbc/do-commands (str "set role " (jdbc/double-quote write-user)))
(try!
(migrate)
(finally
(jdbc/do-commands (str "set role " (jdbc/double-quote orig-user))))))))))
(when-not (empty? (pending-migrations))
(call-with-connections-blocked-during-migration
db-name
(distinct [read-user write-user])
(fn []
;; So new tables, etc. are owned by the write-user
(jdbc/do-commands (str "set role " (jdbc/double-quote write-user)))
(try!
(migrate)
(finally
(jdbc/do-commands (str "set role " (jdbc/double-quote orig-user)))))))))))

(defn initialize-schema
"Ensures the database is migrated to the latest version, and returns
Expand Down

0 comments on commit f768ede

Please sign in to comment.