question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

FlywayException: Unable to calculate checksum Input length = 1

See original GitHub issue
Which 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:closed
  • Created 3 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
juliahaywardcommented, Apr 1, 2020

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.

0reactions
juliahaywardcommented, Apr 27, 2020

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 ä into ae and save in UTF-8 encoding - switching FLyway’s default to UTF-16 will involve redoing the checksums with another repair.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Flyway Error - When I run migrate command. I get "Unable to ...
Flyway Error - When I run migrate command. I get "Unable to calculate checksum" ... And I've got this error. ... The file's...
Read more >
Flyway Gotchas - Redgate Software
Flyway : ERROR: Unable to calculate checksum of V1.0.0__FirstRelease.sql At line:3 char:1 + ... MalformedInputException: Input length = 1.
Read more >
Flyway Error - When I Run Migrate Command. I Get "Unable ...
following error: Unable to calculate checksum for V001.001BaselineScript.sql: Input length 1 The source. When Flyway commands fail they throw an exception with ...
Read more >
Re: Issue 183 in flyway: Calculation of checksum is platform ...
UTF-8. Here is my scenario: 1. The first time I run this in Linux. The scripts are run successfully. ... get the checksum...
Read more >
Flyway can't calculate the checksum of a large SQL script
Unable to calculate checksum for V001.001__BaselineScript.sql: Input length = 1 : Running flyway info failed: "C:\Program ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found