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
MigrationInfoImpl violates the compareTo contract #1249
Comments
+1 vote using Oracle 12c (12.1.0.2.0)
|
Should outOfOrder() in FlywayMediumTest be fixed too, as now the pending migrations come after the installed ones? So the assertion for PENDING status now points to wrong item in the array? |
We built from master with Axel's fix and it solved the problems we had in our environment. |
MigrationInfoImpl compareTo violates the required contract for repeatable migrations, i.e. those with a null version.
Migration 1: R__C.sql is applied - installed rank is 5
Migration 2: R__A.sql is applied - installed rank is 10
For migration 3 there is a new repeatable migration, R__B.sql. If these 3 objects are compared in MigrationInfoImpl.compareTo then:
R__C.sql < R__A.sql (Due to installed rank)
R__B.sql < R__C.sql (Due to alphabetical order)
R__A.sql < R__B.sql (Due to alphabetical order)
This is logically impossible and causes the sort method to throw an exception. But not reliably, it depends on the internal workings of the sort method.
What version of Flyway are you using?
4.0
What database are you using (type & version)?
SQL Server 2012
What operating system are you using?
Windows XP
What did you do?
I have some normal migrations and a bunch of repeatable migrations. The defect occurs when there are existing applied repeatable migrations and some new repeatable migrations.
What did you expect to see?
That the new repeatable migrations would be applied.
What did you see instead?
Exception from sorting collection of MigrationInfoImpl
java.lang.IllegalArgumentException: Comparison method violates its general contract!
at java.util.TimSort.mergeLo(TimSort.java:747)
at java.util.TimSort.mergeAt(TimSort.java:483)
at java.util.TimSort.mergeCollapse(TimSort.java:410)
at java.util.TimSort.sort(TimSort.java:214)
at java.util.TimSort.sort(TimSort.java:173)
at java.util.Arrays.sort(Arrays.java:659)
at java.util.Collections.sort(Collections.java:217)
The text was updated successfully, but these errors were encountered: