Duplicate key name error after migration to latest version

Ce La Vi2 years ago
2022-09-18 11:44:58  INFO: Operating system name: Linux version: 4.4.0-1128-aws architecture: amd64
2022-09-18 11:44:59  INFO: Java runtime name: OpenJDK 64-Bit Server VM vendor: ojdkbuild version: 11.0.15+10-LTS
2022-09-18 11:44:59  INFO: Memory limit heap: 988mb non-heap: 0mb
2022-09-18 11:44:59  INFO: Character encoding: UTF-8 charset: UTF-8
2022-09-18 11:44:59  INFO: Version: 5.3
2022-09-18 11:44:59  INFO: Starting server...
2022-09-18 11:44:59  INFO: HikariPool-1 - Starting...
2022-09-18 11:44:59  INFO: HikariPool-1 - Added connection com.mysql.cj.jdbc.ConnectionImpl@d71adc2
2022-09-18 11:44:59  INFO: HikariPool-1 - Start completed.
2022-09-18 11:44:59  INFO: Clearing database change log checksums
2022-09-18 11:45:00  INFO: Successfully acquired change log lock
2022-09-18 11:45:00  INFO: Successfully released change log lock
2022-09-18 11:45:00  INFO: Successfully acquired change log lock
2022-09-18 11:45:00  INFO: Cannot load service: liquibase.parser.ChangeLogParser: liquibase.parser.core.json.JsonChangeLogParser Unable to get public no-arg constructor
2022-09-18 11:45:00  INFO: Cannot load service: liquibase.parser.ChangeLogParser: liquibase.parser.core.yaml.YamlChangeLogParser Unable to get public no-arg constructor
2022-09-18 11:45:01  INFO: Reading from xxxx.DATABASECHANGELOG
2022-09-18 11:45:02  INFO: Reading from xxxx.DATABASECHANGELOG
2022-09-18 11:45:02  INFO: Cannot load service: liquibase.hub.HubService: Provider liquibase.hub.core.StandardHubService could not be instantiated
2022-09-18 11:45:02  INFO: Successfully released change log lock
2022-09-18 11:45:02 ERROR: Main method error - 
com.google.inject.ProvisionException: Unable to provision, see the following errors:

1) [Guice/ErrorInCustomProvider]: LiquibaseException: MigrationFailedException: Migration failed for change set changelog-4.9::changelog-4.9::author:
     Reason: DatabaseException: Duplicate key name 'event_deviceid_servertime' [Failed SQL: (1061) CREATE INDEX event_deviceid_servertime ON xxxx.tc_events(deviceid, servertime)]
  at DatabaseModule.provideDataSource(DatabaseModule.java:46)
  at DatabaseStorage.<init>(DatabaseStorage.java:48)
      \_ for 2nd parameter
  while locating DatabaseStorage
  while locating Storage

Learn more:
  https://github.com/google/guice/wiki/ERROR_IN_CUSTOM_PROVIDER

1 error
Macan2 years ago

Hello,

truncate database and try import it again.

Swanhteta year ago

i have a similar error when i upgrade version 4.4 to 5.*. Database migration is fail every time if there are already data in database.Can someone help?

Anton Tananaeva year ago

It probably means that your schema is already corrupted.

Swanhtet10 months ago

Hi @Anton ,

I did restore the database everytime when i rebuild. but I got this error similar to the OP.

ERROR: Change Set changelog-4.9::changelog-4.9::author failed.  Error: Duplicate key name 'event_deviceid_servertime' [Failed SQL: (1061) CREATE INDEX event_deviceid_servertime ON traccar.tc_events(deviceid, servertime)]

also how can i check the database schema is corrupted , sry i am very new this.

Anton Tananaev10 months ago

You already have the index in the database. Either remove the index from the database or the changelog.

Swanhtet10 months ago

Thanks @Anton , It is working now. if anyone wondering , as the error said, it was creating the indexes which are already created by earlier changelogs.I think you can even delete the entire 4.9 changelog since all it was doing was creating those indexes.