ERROR: Unable to release PostgreSQL advisory lock
See original GitHub issueWhich version and edition of Flyway are you using?
Flyway Community Edition 7.8.2
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)
N/A
Which client are you using? (Command-line, Java API, Maven plugin, Gradle plugin)
Command-line
Which database are you using? (Type & version)
PostgreSQL 11.11
Which operating system are you using?
macOS Big Sur 11.3.1
What did you do? (Please include the content causing the issue, any relevant configuration settings, the SQL statement(s) that failed (if any), and the command you ran)
Tried running flyway migration using command line option
/usr/local/bin/flyway -user=postgres -password=password -url=jdbc:postgresql://localhost:5432/mydb -locations=filesystem:/Users/myuser/flyway/app,filesystem:/Users/myuser/flyway/appconfig/**/* -cleanDisabled=true migrate info
What did you expect to see?
Migration to succeed
What did you see instead?
Flyway error
ERROR: Unable to rollback transaction
org.postgresql.util.PSQLException: This connection has been closed.
at org.postgresql.jdbc.PgConnection.checkClosed(PgConnection.java:877)
at org.postgresql.jdbc.PgConnection.rollback(PgConnection.java:884)
at org.flywaydb.core.internal.jdbc.TransactionalExecutionTemplate.execute(TransactionalExecutionTemplate.java:82)
at org.flywaydb.core.internal.command.DbMigrate.applyMigrations(DbMigrate.java:261)
at org.flywaydb.core.internal.command.DbMigrate.migrateGroup(DbMigrate.java:234)
at org.flywaydb.core.internal.command.DbMigrate.lambda$migrateAll$0(DbMigrate.java:140)
at org.flywaydb.core.internal.database.postgresql.PostgreSQLAdvisoryLockTemplate.execute(PostgreSQLAdvisoryLockTemplate.java:69)
at org.flywaydb.core.internal.database.postgresql.PostgreSQLConnection.lock(PostgreSQLConnection.java:99)
at org.flywaydb.core.internal.schemahistory.JdbcTableSchemaHistory.lock(JdbcTableSchemaHistory.java:141)
at org.flywaydb.core.internal.command.DbMigrate.migrateAll(DbMigrate.java:140)
at org.flywaydb.core.internal.command.DbMigrate.migrate(DbMigrate.java:100)
at org.flywaydb.core.Flyway$1.execute(Flyway.java:214)
at org.flywaydb.core.Flyway$1.execute(Flyway.java:165)
at org.flywaydb.core.Flyway.execute(Flyway.java:569)
at org.flywaydb.core.Flyway.migrate(Flyway.java:165)
at org.flywaydb.commandline.Main.executeOperation(Main.java:223)
at org.flywaydb.commandline.Main.main(Main.java:148)
ERROR: Unable to restore autocommit to original value for connection
org.postgresql.util.PSQLException: This connection has been closed.
at org.postgresql.jdbc.PgConnection.checkClosed(PgConnection.java:877)
at org.postgresql.jdbc.PgConnection.setAutoCommit(PgConnection.java:806)
at org.flywaydb.core.internal.jdbc.TransactionalExecutionTemplate.execute(TransactionalExecutionTemplate.java:97)
at org.flywaydb.core.internal.command.DbMigrate.applyMigrations(DbMigrate.java:261)
at org.flywaydb.core.internal.command.DbMigrate.migrateGroup(DbMigrate.java:234)
at org.flywaydb.core.internal.command.DbMigrate.lambda$migrateAll$0(DbMigrate.java:140)
at org.flywaydb.core.internal.database.postgresql.PostgreSQLAdvisoryLockTemplate.execute(PostgreSQLAdvisoryLockTemplate.java:69)
at org.flywaydb.core.internal.database.postgresql.PostgreSQLConnection.lock(PostgreSQLConnection.java:99)
at org.flywaydb.core.internal.schemahistory.JdbcTableSchemaHistory.lock(JdbcTableSchemaHistory.java:141)
at org.flywaydb.core.internal.command.DbMigrate.migrateAll(DbMigrate.java:140)
at org.flywaydb.core.internal.command.DbMigrate.migrate(DbMigrate.java:100)
at org.flywaydb.core.Flyway$1.execute(Flyway.java:214)
at org.flywaydb.core.Flyway$1.execute(Flyway.java:165)
at org.flywaydb.core.Flyway.execute(Flyway.java:569)
at org.flywaydb.core.Flyway.migrate(Flyway.java:165)
at org.flywaydb.commandline.Main.executeOperation(Main.java:223)
at org.flywaydb.commandline.Main.main(Main.java:148)
ERROR: Migration of schema "public" with repeatable migration "labels" failed! Changes successfully rolled back.
ERROR: Unable to release PostgreSQL advisory lock
org.postgresql.util.PSQLException: This connection has been closed.
at org.postgresql.jdbc.PgConnection.checkClosed(PgConnection.java:877)
at org.postgresql.jdbc.PgConnection.prepareStatement(PgConnection.java:1735)
at org.postgresql.jdbc.PgConnection.prepareStatement(PgConnection.java:428)
at org.flywaydb.core.internal.jdbc.JdbcTemplate.prepareStatement(JdbcTemplate.java:344)
at org.flywaydb.core.internal.jdbc.JdbcTemplate.queryForBoolean(JdbcTemplate.java:170)
at org.flywaydb.core.internal.database.postgresql.PostgreSQLAdvisoryLockTemplate.unlock(PostgreSQLAdvisoryLockTemplate.java:101)
at org.flywaydb.core.internal.database.postgresql.PostgreSQLAdvisoryLockTemplate.execute(PostgreSQLAdvisoryLockTemplate.java:80)
at org.flywaydb.core.internal.database.postgresql.PostgreSQLConnection.lock(PostgreSQLConnection.java:99)
at org.flywaydb.core.internal.schemahistory.JdbcTableSchemaHistory.lock(JdbcTableSchemaHistory.java:141)
at org.flywaydb.core.internal.command.DbMigrate.migrateAll(DbMigrate.java:140)
at org.flywaydb.core.internal.command.DbMigrate.migrate(DbMigrate.java:100)
at org.flywaydb.core.Flyway$1.execute(Flyway.java:214)
at org.flywaydb.core.Flyway$1.execute(Flyway.java:165)
at org.flywaydb.core.Flyway.execute(Flyway.java:569)
at org.flywaydb.core.Flyway.migrate(Flyway.java:165)
at org.flywaydb.commandline.Main.executeOperation(Main.java:223)
at org.flywaydb.commandline.Main.main(Main.java:148)
Issue Analytics
- State:
- Created 2 years ago
- Comments:10 (5 by maintainers)
Top Results From Across the Web
Connection Terminated / Unable to release PostgreSQL ...
ERROR: Unable to release PostgreSQL advisory lock org.postgresql.util.PSQLException: This connection has been closed.
Read more >Flyway, Postgresql, Unable to acquire Flyway advisory lock
We had a transaction that updates 2000000 rows in a postgresql 10 database using flyway (v6). It failed with Unable to acquire Flyway...
Read more >timed out trying to acquire postgres advisory lock ... - Fly.io
For the past four hours, I've been encountering a strange issue where my linting, unit tests, E2E tests, and build pass but the...
Read more >Advisory Locks in PostgreSQL - Hashrocket
Advisory Locks can be acquired at the session level or the transaction level, meaning if acquired within a transaction, an Advisory Lock will...
Read more >Documentation: 15: 13.3. Explicit Locking - PostgreSQL
Once acquired at session level, an advisory lock is held until explicitly released or the session ends.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Your
locations
need to be correct for the docker container - you need to replace/Users/myuser/flyway
with/flyway/sql
Yes. It might be that
tcpkeepalive
isn’t being used for the connection. See this which suggests that you need to enable it per socket, or setnet.inet.tcp.always_keepalive
to1
Closing as there isn’t any action for Flyway to take