Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When using script config executeInTransaction=false and script contains syntax error, error is "ERROR: Unable to release PostgreSQL advisory lock" instead of the actual error. #2800

Closed
LHCGreg opened this issue May 1, 2020 · 3 comments

Comments

@LHCGreg
Copy link

LHCGreg commented May 1, 2020

Which version and edition of Flyway are you using?

Flyway Community Edition 6.4.1

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)
This is the latest version.

Which client are you using? (Command-line, Java API, Maven plugin, Gradle plugin)

Command-line

Which database are you using (type & version)?

PostgreSQL 12.2

Which operating system are you using?

Flyway is running on Windows, PostgreSQL is running on the postgres:12.2 docker image.

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.)

flyway.conf:

flyway.locations=filesystem:.
flyway.mixed=true
flyway.cleanDisabled=true

V1__initial_schema.sql:

BEGIN TRANSACTION;

CREATE TABLE thing
(
  thing_id int NOT NULL PRIMARY KEY, -- trailing comma after last column is a syntax error
);

COMMIT TRANSACTION;

V1__initial_schema.sql.conf:

executeInTransaction=false

I ran

C:\projects\flyway_test_1>flyway -url="jdbc:postgresql://localhost:6543/flyway_test" -user=postgres -password=postgres_pw migrate
What did you expect to see?

I expected to see an error message about the syntax error in the script.

What did you see instead?
C:\projects\flyway_test_1>flyway -url="jdbc:postgresql://localhost:6543/flyway_test" -user=postgres -password=postgres_pw migrate
Flyway Community Edition 6.4.1 by Redgate
Database: jdbc:postgresql://localhost:6543/flyway_test (PostgreSQL 12.2)
Successfully validated 1 migration (execution time 00:00.018s)
Creating Schema History table "public"."flyway_schema_history" ...
Current version of schema "public": << Empty Schema >>
Migrating schema "public" to version 1 - initial schema [non-transactional]
ERROR: Migration of schema "public" to version 1 - initial schema [non-transactional] failed! Please restore backups and roll back database and code!
ERROR: Unable to release PostgreSQL advisory lock
@juliahayward
Copy link
Member

juliahayward commented May 6, 2020

The problem is the command line is only reporting the top-level error message; we'll add a fix for 6.4.2 that tracks through nested exceptions and reports the ultimate root cause. This should be only a few days away. In the meantime, the -X option does log the full error stack and reveals the syntax error.

@atejano
Copy link

atejano commented Jul 6, 2020

Any workaround to resolve this issue in my current flyway migrate?

@juliahayward
Copy link
Member

juliahayward commented Jul 7, 2020

Have you tried updating to the latest version? 6.5.0 is now released.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants