FlywayException: Unable to calculate checksum Input length = 1
See original GitHub issueWhich version and edition of Flyway are you using?
Flyway Community Edition 6.3.2 by Redgate
If this is not the latest version, can you reproduce the issue with the latest one as well?
This is the latest currently available.
Which client are you using? (Command-line, Java API, Maven plugin, Gradle plugin)
Command line, Windows 10
Which database are you using (type & version)?
Database: jdbc:postgresql://localhost:5432/mydb (PostgreSQL 12.2) DEBUG: Driver : PostgreSQL JDBC Driver 42.2.8.jre6
Which operating system are you using?
Windows 10 Pro; x64
What did you do?
We have around 200 migration scripts, that runs fine with flyway 5.1.1 on a ubuntu system. I copied (backup/restore) the DB from that system to local postgres:alpine docker; DB runs fine, but is somewhat outdated so I have to run flyway to get the recent schema updates.
So I run flyway -configFiles=mylocal.cfg migrate -X > migrate.log 2>&1
Config file:
flyway.url=jdbc:postgresql://localhost:5432/${DBANK}
flyway.user=postgres
flyway.password=postgres
flyway.mixed=true
flyway.locations=filesystem:banken/${DBANK}
flyway.baselineDescription=Stand: 1.Juni.2018
Environment variable set DBANK=mydb
What did you expect to see?
Successful migration takes place.
What did you see instead?
DEBUG: Memory usage: 11 of 256M
ERROR: Unexpected error
org.flywaydb.core.api.FlywayException: Unable to calculate checksum Input length = 1
at org.flywaydb.core.internal.resolver.ChecksumCalculator.calculateChecksumForReader(ChecksumCalculator.java:80)
at org.flywaydb.core.internal.resolver.ChecksumCalculator.calculate(ChecksumCalculator.java:46)
at org.flywaydb.core.internal.resolver.sql.SqlMigrationResolver.getChecksumForLoadableResource(SqlMigrationResolver.java:143)
at org.flywaydb.core.internal.resolver.sql.SqlMigrationResolver.addMigrations(SqlMigrationResolver.java:181)
at org.flywaydb.core.internal.resolver.sql.SqlMigrationResolver.resolveMigrations(SqlMigrationResolver.java:88)
at org.flywaydb.core.internal.resolver.sql.SqlMigrationResolver.resolveMigrations(SqlMigrationResolver.java:44)
at org.flywaydb.core.internal.resolver.CompositeMigrationResolver.collectMigrations(CompositeMigrationResolver.java:127)
at org.flywaydb.core.internal.resolver.CompositeMigrationResolver.doFindAvailableMigrations(CompositeMigrationResolver.java:109)
at org.flywaydb.core.internal.resolver.CompositeMigrationResolver.resolveMigrations(CompositeMigrationResolver.java:95)
at org.flywaydb.core.internal.resolver.CompositeMigrationResolver.resolveMigrations(CompositeMigrationResolver.java:46)
at org.flywaydb.core.internal.info.MigrationInfoServiceImpl.refresh(MigrationInfoServiceImpl.java:130)
at org.flywaydb.core.internal.command.DbRepair$1.call(DbRepair.java:104)
at org.flywaydb.core.internal.command.DbRepair$1.call(DbRepair.java:101)
at org.flywaydb.core.internal.jdbc.TransactionalExecutionTemplate.execute(TransactionalExecutionTemplate.java:66)
at org.flywaydb.core.internal.command.DbRepair.repair(DbRepair.java:101)
at org.flywaydb.core.Flyway$6.execute(Flyway.java:370)
at org.flywaydb.core.Flyway$6.execute(Flyway.java:363)
at org.flywaydb.core.Flyway.execute(Flyway.java:523)
at org.flywaydb.core.Flyway.repair(Flyway.java:363)
at org.flywaydb.commandline.Main.executeOperation(Main.java:211)
at org.flywaydb.commandline.Main.main(Main.java:128)
Caused by: java.nio.charset.MalformedInputException: Input length = 1
at java.base/java.nio.charset.CoderResult.throwException(Unknown Source)
at java.base/sun.nio.cs.StreamDecoder.implRead(Unknown Source)
at java.base/sun.nio.cs.StreamDecoder.read(Unknown Source)
at java.base/java.io.BufferedReader.fill(Unknown Source)
at java.base/java.io.BufferedReader.readLine(Unknown Source)
at java.base/java.io.BufferedReader.readLine(Unknown Source)
at org.flywaydb.core.internal.resolver.ChecksumCalculator.calculateChecksumForReader(ChecksumCalculator.java:69)
... 20 more
For your info I attached a line endings report of the SQL files involved, because some q/a at stackoverflow reported that this might be an issue:
lineendingsreport.txt
But I changed yet the few files in question to all use CRLF for a local test - without any other effect as the error reported above.
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (4 by maintainers)
There were changes around checksum calculation between v5 and v6 - that may well be the cause of errors appearing. 6.3.3 should be released next Monday, this will at least help you pinpoint which file is causing problems.
Indeed, I found there is one character which prevents the file being read as UTF-8, and that’s in the comment
--tätigkeiten---------------------------------
I guess the simplest workaround is to expand
ä
intoae
and save in UTF-8 encoding - switching FLyway’s default to UTF-16 will involve redoing the checksums with anotherrepair
.