PostgreSQL search path not restored properly after migrations when auto-comit == false. #1959
Which version and edition of Flyway are you using?
If this is not the latest version, can you reproduce the issue with the latest one as well?
(Many bugs are fixed in newer releases and upgrading will often resolve the issue)
Initially noticed with 5.0.5, repeated with 5.0.7. Seems problematic with current code in master (only from code inspection, I haven't actually tried it).
Which client are you using? (Command-line, Java API, Maven plugin, Gradle plugin)
Which database are you using (type & version)?
Which operating system are you using?
What did you do?
(Please include the content causing the issue, any relevant configuration settings, the SQL statement that failed (if relevant) and the command you ran.)
Migrating multiple db schemas via multiple
Relevant part of code:
Code above is common for several modules/classes, all using same (Spring-injected)
We're running database migrations for all system modules upon system startup, sequentially (no parallel execution). Several db schemas contain views with same name (
What did you expect to see?
The expectation was that DB migrations for each schema were completely isolated from each other (and hence that
What did you see instead?
In this specific scenario, we already had one existing schema (let's call it
What happened was following:
After some debugging we found out that the problem is that restoring of current schema in
In our case, migrations for schema
I've checked current state of related code here on GitHub, and although it is refactored quite a bit, the problem seems to still be there (restoring is done in
The text was updated successfully, but these errors were encountered:
We completely reimplemented search_path support on the master branch as part of the changes for #1926.
I am unable to reproduce the scenario you described here with that code.
Please build the latest sources, try again and confirm it is now working for you.
Thanks for checking. Then we must be missing something in our reproduction test case, as in our tests the search_path is always properly restored. How exactly is your datasource configured? Or even better, could you share a small repo that reproduces the problem?
Datasource is configured via Spring Boot, using HikariCP (version 2.7.8).
From my understanding, the problem (with latest code) is in following:
Since there is no transaction around entire database/connection closing, nor around
The problem does not appear with following config change:
If this doesn't help, I'll try to produce minimal test project.
Thank you so much for the sample project. That was immensely useful. Somehow we could only ever reproduce this with HikariCP and not with any of the other datasources we normally use. I still haven't fully figured out why, but at least we now have a reliable way to verify this. Fixed.