Changeset checksum validation failed with same md5sum value

Hi Everyone,

We are using liquibase-core 3.4.1 version. we are migrating the db changes through the  changelog sql file for postgres database. Below is the code for migration.

  liquibase = new liquibase.Liquibase(“db/<my_app_databasechange_log>.sql”, new ClassLoaderResourceAccessor(), database);

liquibase.update(new Contexts(), new LabelExpression());

we added few changesets to the my_app_databasechange_log.sql file and ran it in local, it worked fine. When we moved to another environment(QA) it is failing with below error for existing changeset which is 10 changesets above from the newly added changeset. 

The error is showing the same md5sum as what is there in the databasechangelog table.

lvl":“ERROR”,“msg”:"",“exception”:"liquibase.exception.ValidationFailedException: Validation Failed:\n     1 change sets check sum\n          db/<my_app_databasechange_log>.sql::<change_set_name>::o is now: 7:<old_md5sum>

Could you please help here.

Thanks

Sravan A

Hi Steve, 

I tried to print the checksum values current Changeset and old Changeset ( RanChangeset) for the changeset which are failed during the validation.

The RanChangeSet checksum value is different than what is existing in the detabasechangelog table md5sum value.

What could be the reason for printing the different value from what exists in database.

  validationFailedException.getInvalidMD5Sums().forEach(changeSet -> {

                         try {

                             finalDatabase.getRanChangeSetList().forEach((ranChangeSet -> {

                                     if(ranChangeSet.getId().equals(changeSet.getId())){

                                         logger.error("db changeset id:: " +ranChangeSet.getId() 

                                             + " checksum:: "+ranChangeSet.getLastCheckSum() + “\n current changeset id:: " + changeSet.getId()  +” current checksum:: "+ changeSet.generateCheckSum());

                                     }

                                 })

                             );

                         } catch (DatabaseException e1) {

                             e1.printStackTrace();

                         }

                     });

Thanks

Sravan A

Hi Steve,

Thanks for answering the question.

We did not update the version of liquibase version and it is 3.41. 

Below is the databasechangelog record for the existing changeset which is failing.

idmy_table_index_column1_alt current checksum:: 7:b7cfd7492431756ad5b4ee5ea769202f

Could you show the actual error message and the contents of the DATABASECHANGELOG table? Please remove any sensitive info from the logs if needed. 

Steve Donie
Principal Software Engineer
Datical, Inc. http://www.datical.com/

What happened when you tried? Did it fail? I’m still not clear what your error is. 

The reason that you get that error message is that some changesets have been deployed to a database. At the time they were deployed, Liquibase calculated a checksum for each changeset. If you then run update again, Liquibase checks two things - whether each changeset in the changelog has been deployed before or not, which is does by comparing the changeset id, author, and path that in in the changelog to the entries in the DATABASECHANGELOG table. Liquibase also calculates a checksum for each changeset in the changelog again, and then compares that checksum to any that are in the DATABASECHANGELOG table. If they are different, that is an error.

Typically, this should only happen if the changeset has actually been changed between the first deploy and the second deploy. If you are certain that the changeset has NOT changed, then you can work around the problem by manually clearing the checksum column from that row, and Liquibase will just update the checksum - it won’t try to re-apply the changeset, but will just re-calculate the checksum. 

There are also cases where the checksum algorithm has changed - this has happened a few times in the lifetime history of Liquibase. The number with the colon preceeding the checksum is the version of the checksum algorithm. In your first post, the partial message you included showed a version of 7.

If you have recently updated the version of Liquibase you are using, that could be the issue. In that case, you can use the Liquibase clearChecksums command after you have verified that the changelog hasn’t been altered from what it should be, and then re-run the update command, and Liquibase will update the checksums as described above. 

Again, without a full description of what you did, and the full output of the errors, it is difficult to help more. 

Steve Donie
Principal Software Engineer
Datical, Inc. http://www.datical.com/