Getting DB migration error when running multiple Metabase using Docker Image

After creating a new Metabase instance with a new application DB using docker image in the same machine, the new Metabase pod is crashing with the below error. The existing one is running fine.

2022-09-19 09:33:36,257 INFO db.liquibase :: Database has unrun migrations. Waiting for migration lock to be cleared...
2022-09-19 09:33:36,364 INFO db.liquibase :: Migration lock is cleared. Running migrations...
2022-09-19 09:33:36,581 ERROR metabase.core :: Metabase Initialization FAILED
liquibase.exception.LiquibaseException: liquibase.exception.MigrationFailedException: Migration failed for change set migrations/000_migrations.yaml::1::agilliland:
Reason: liquibase.exception.DatabaseException: ERROR: relation "core_user" already exists [Failed SQL: (0) CREATE TABLE "public"."core_user" ("id" INTEGER GENERATED BY DEFAULT AS IDENTITY NOT NULL, "email" VARCHAR(254) NOT NULL, "first_name" VARCHAR(254) NOT NULL, "last_name" VARCHAR(254) NOT NULL, "password" VARCHAR(254) NOT NULL, "password_salt" VARCHAR(254) DEFAULT 'default' NOT NULL, "date_joined" TIMESTAMP WITH TIME ZONE NOT NULL, "last_login" TIMESTAMP WITH TIME ZONE, "is_staff" BOOLEAN NOT NULL, "is_superuser" BOOLEAN NOT NULL, "is_active" BOOLEAN NOT NULL, "reset_token" VARCHAR(254), "reset_triggered" BIGINT, CONSTRAINT "core_user_pkey" PRIMARY KEY ("id"), UNIQUE ("email"))]
at liquibase.changelog.ChangeLogIterator.run(ChangeLogIterator.java:126)
at liquibase.Liquibase.lambda$null$0(Liquibase.java:265)
at liquibase.Scope.lambda$child$0(Scope.java:180)
at liquibase.Scope.child(Scope.java:189)
at liquibase.Scope.child(Scope.java:179)
at liquibase.Scope.child(Scope.java:158)
at liquibase.Scope.child(Scope.java:243)
at liquibase.Liquibase.lambda$update$1(Liquibase.java:264)
at liquibase.Scope.lambda$child$0(Scope.java:180)
at liquibase.Scope.child(Scope.java:189)
at liquibase.Scope.child(Scope.java:179)
at liquibase.Scope.child(Scope.java:158)
at liquibase.Liquibase.runInScope(Liquibase.java:2405)
at liquibase.Liquibase.update(Liquibase.java:211)
at liquibase.Liquibase.update(Liquibase.java:197)
at liquibase.Liquibase.update(Liquibase.java:193)
at metabase.db.liquibase$migrate_up_if_needed_BANG_.invokeStatic(liquibase.clj:142)
at metabase.db.liquibase$migrate_up_if_needed_BANG_.invoke(liquibase.clj:130)
at metabase.db.setup$fn__34835$migrate_BANG___34840$fn__34841$fn__34842.invoke(setup.clj:68)
at metabase.db.liquibase$fn__30492$do_with_liquibase__30497$fn__30498.invoke(liquibase.clj:59)
at metabase.db.liquibase$fn__30492$do_with_liquibase__30497.invoke(liquibase.clj:51)
at metabase.db.setup$fn__34835$migrate_BANG___34840$fn__34841.invoke(setup.clj:63)
at metabase.db.setup$fn__34835$migrate_BANG___34840.invoke(setup.clj:40)
at metabase.db.setup$fn__34894$run_schema_migrations_BANG___34899$fn__34900.invoke(setup.clj:121)
at metabase.db.setup$fn__34894$run_schema_migrations_BANG___34899.invoke(setup.clj:115)
at metabase.db.setup$fn__34946$setup_db_BANG___34951$fn__34952$fn__34955$fn__34956.invoke(setup.clj:147)
at metabase.util$do_with_us_locale.invokeStatic(util.clj:715)
at metabase.util$do_with_us_locale.invoke(util.clj:701)
at metabase.db.setup$fn__34946$setup_db_BANG___34951$fn__34952$fn__34955.invoke(setup.clj:145)
at metabase.db.setup$fn__34946$setup_db_BANG___34951$fn__34952.invoke(setup.clj:144)
at metabase.db.setup$fn__34946$setup_db_BANG___34951.invoke(setup.clj:138)
at metabase.db$setup_db_BANG_$fn__34981.invoke(db.clj:65)
at metabase.db$setup_db_BANG_.invokeStatic(db.clj:60)
at metabase.db$setup_db_BANG_.invoke(db.clj:51)
at metabase.core$init_BANG__STAR_.invokeStatic(core.clj:98)
at metabase.core$init_BANG__STAR_.invoke(core.clj:81)
at metabase.core$init_BANG_.invokeStatic(core.clj:138)
at metabase.core$init_BANG_.invoke(core.clj:133)
at metabase.core$start_normally.invokeStatic(core.clj:150)
at metabase.core$start_normally.invoke(core.clj:144)
at metabase.core$_main.invokeStatic(core.clj:183)
at metabase.core$_main.doInvoke(core.clj:177)
at clojure.lang.RestFn.invoke(RestFn.java:397)
at clojure.lang.AFn.applyToHelper(AFn.java:152)
at clojure.lang.RestFn.applyTo(RestFn.java:132)
at metabase.core.main(Unknown Source)
Caused by: liquibase.exception.MigrationFailedException: Migration failed for change set migrations/000_migrations.yaml::1::agilliland:

I am using this docker image:
"image": "metabase/metabase:v0.43.3"

Hi @safvanplp
So you have two completely separate Docker containers which are referencing completely different application databases?
If both containers are referencing the same application database, then you have a problem in the databasechangelog table, since it seems to have lost all its information, which means that it doesn't know the migration state and tries to apply everything again.

@flamber
Yes. I have two docker containers referring to different databases.

As of now, it has been resolved. The steps I have done are,

  1. Took the backup of Metabase Application DB (Postgres) using pg_dump
  2. Dropped all the tables in the database
  3. Restored the database using pg_restore

After that, the pods got started without any issues. Even though I am not sure what is the actual root cause, the problem seems to be solved.

Thanks @flamber for your input.