Skip to content
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

Flyway problem after kubernetes restart #353

Closed
oliverbusch opened this issue Jun 14, 2024 · 4 comments
Closed

Flyway problem after kubernetes restart #353

oliverbusch opened this issue Jun 14, 2024 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@oliverbusch
Copy link

Current Behavior

After restarting Kubernetes, the alice-tractusx-connector-controlplane cannot be started due to a flyway error.

2024-06-13 13:55:41] [INFO   ] Current version of schema "public": 0.0.2
[2024-06-13 13:55:41] [INFO   ] Migrating schema "public" to version "0.0.3 - Add StatefulEntity Columns"
[2024-06-13 13:55:41] [SEVERE ] Migration of schema "public" to version "0.0.3 - Add StatefulEntity Columns" failed! Changes successfully rolled back.
SEVERE 2024-06-13T13:55:41.344506517 Error booting runtime: Migration V0_0_3__Add_StatefulEntity_Columns.sql failed ------------------------------------------------------- SQL State  : 42701 Error Code : 0 Message    : ERROR: column "expiration_timestamp" of relation "edc_edr_cache" already exists Location   : org/eclipse/tractusx/edc/postgresql/migration/edr/V0_0_3__Add_StatefulEntity_Columns.sql (/app/file:/app/edc-controlplane.jar!/org/eclipse/tractusx/edc/postgresql/migration/edr/V0_0_3__Add_StatefulEntity_Columns.sql) Line       : 18 Statement  : -- --  Copyright (c) 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) -- --  This program and the accompanying materials are made available under the --  terms of the Apache License, Version 2.0 which is available at --  https://www.apache.org/licenses/LICENSE-2.0 -- --  SPDX-License-Identifier: Apache-2.0 -- --  Contributors: --       Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - initial API and implementation --  -- Statements are designed for and tested with Postgres only!   -- add column ALTER TABLE edc_edr_cache ADD COLUMN expiration_timestamp BIGINT
org.flywaydb.core.internal.command.DbMigrate$FlywayMigrateException: Migration V0_0_3__Add_StatefulEntity_Columns.sql failed
-------------------------------------------------------
SQL State  : 42701
Error Code : 0
Message    : ERROR: column "expiration_timestamp" of relation "edc_edr_cache" already exists
Location   : org/eclipse/tractusx/edc/postgresql/migration/edr/V0_0_3__Add_StatefulEntity_Columns.sql (/app/file:/app/edc-controlplane.jar!/org/eclipse/tractusx/edc/postgresql/migration/edr/V0_0_3__Add_StatefulEntity_Columns.sql)
Line       : 18
Statement  : --
--  Copyright (c) 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
--
--  This program and the accompanying materials are made available under the
--  terms of the Apache License, Version 2.0 which is available at
--  https://www.apache.org/licenses/LICENSE-2.0
--
--  SPDX-License-Identifier: Apache-2.0
--
--  Contributors:
--       Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - initial API and implementation
--

-- Statements are designed for and tested with Postgres only!


-- add column
ALTER TABLE edc_edr_cache ADD COLUMN expiration_timestamp BIGINT

        at org.flywaydb.core.internal.command.DbMigrate.doMigrateGroup(DbMigrate.java:382)
        at org.flywaydb.core.internal.command.DbMigrate.lambda$applyMigrations$1(DbMigrate.java:272)
        at org.flywaydb.core.internal.jdbc.TransactionalExecutionTemplate.execute(TransactionalExecutionTemplate.java:55)
        at org.flywaydb.core.internal.command.DbMigrate.applyMigrations(DbMigrate.java:271)
        at org.flywaydb.core.internal.command.DbMigrate.migrateGroup(DbMigrate.java:244)
        at org.flywaydb.core.internal.command.DbMigrate.lambda$migrateAll$0(DbMigrate.java:139)
        at org.flywaydb.core.internal.database.postgresql.PostgreSQLAdvisoryLockTemplate.execute(PostgreSQLAdvisoryLockTemplate.java:73)
        at org.flywaydb.core.internal.database.postgresql.PostgreSQLAdvisoryLockTemplate.lambda$execute$0(PostgreSQLAdvisoryLockTemplate.java:56)
        at org.flywaydb.core.internal.jdbc.TransactionalExecutionTemplate.execute(TransactionalExecutionTemplate.java:55)
        at org.flywaydb.core.internal.database.postgresql.PostgreSQLAdvisoryLockTemplate.execute(PostgreSQLAdvisoryLockTemplate.java:56)
        at org.flywaydb.core.internal.database.postgresql.PostgreSQLConnection.lock(PostgreSQLConnection.java:96)
        at org.flywaydb.core.internal.schemahistory.JdbcTableSchemaHistory.lock(JdbcTableSchemaHistory.java:144)
        at org.flywaydb.core.internal.command.DbMigrate.migrateAll(DbMigrate.java:139)
        at org.flywaydb.core.internal.command.DbMigrate.migrate(DbMigrate.java:97)
        at org.flywaydb.core.Flyway.lambda$migrate$0(Flyway.java:188)
        at org.flywaydb.core.FlywayExecutor.execute(FlywayExecutor.java:213)
        at org.flywaydb.core.Flyway.migrate(Flyway.java:140)
        at org.eclipse.tractusx.edc.postgresql.migration.FlywayManager.migrate(FlywayManager.java:48)
        at org.eclipse.tractusx.edc.postgresql.migration.AbstractPostgresqlMigrationExtension.initialize(AbstractPostgresqlMigrationExtension.java:81)
        at org.eclipse.tractusx.edc.postgresql.migration.EdrPostgresqlMigrationExtension.initialize(EdrPostgresqlMigrationExtension.java:22)
        at org.eclipse.edc.boot.system.injection.lifecycle.InitializePhase.initialize(InitializePhase.java:37)
        at org.eclipse.edc.boot.system.injection.lifecycle.ExtensionLifecycleManager.initialize(ExtensionLifecycleManager.java:61)
        at java.base/java.util.stream.ReferencePipeline$3$1.accept(Unknown Source)
        at java.base/java.util.stream.ReferencePipeline$3$1.accept(Unknown Source)
        at java.base/java.util.stream.ReferencePipeline$3$1.accept(Unknown Source)
        at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(Unknown Source)
        at java.base/java.util.stream.AbstractPipeline.copyInto(Unknown Source)
        at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(Unknown Source)
        at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(Unknown Source)
        at java.base/java.util.stream.AbstractPipeline.evaluate(Unknown Source)
        at java.base/java.util.stream.ReferencePipeline.collect(Unknown Source)
        at org.eclipse.edc.boot.system.ExtensionLoader.bootServiceExtensions(ExtensionLoader.java:67)
        at org.eclipse.edc.boot.system.runtime.BaseRuntime.bootExtensions(BaseRuntime.java:139)
        at org.eclipse.edc.boot.system.runtime.BaseRuntime.boot(BaseRuntime.java:200)
        at org.eclipse.edc.boot.system.runtime.BaseRuntime.boot(BaseRuntime.java:83)
        at org.eclipse.edc.boot.system.runtime.BaseRuntime.main(BaseRuntime.java:71)
Caused by: org.flywaydb.core.internal.sqlscript.FlywaySqlScriptException: Migration V0_0_3__Add_StatefulEntity_Columns.sql failed

Expected Behavior

After restarting Kubernetes, all containers should start without any problems.

Steps To Reproduce

Restart the kubernetes cluster
Main Branch (pull date 05.06.24)

@oliverbusch oliverbusch added the bug Something isn't working label Jun 14, 2024
@hemantxpatel hemantxpatel self-assigned this Jun 19, 2024
@hemantxpatel
Copy link
Contributor

hemantxpatel commented Jun 19, 2024

Hi @oliverbusch, Kubernetes cluster created by kind should not be restarted. If you somehow restart the cluster, it may not work as expected, and you need to re-create the cluster.
Please see below references:
kubernetes-sigs/kind#148
https://discuss.kubernetes.io/t/restart-a-kind-cluster/5413/4

@oliverbusch
Copy link
Author

Hello @hemantxpatel, I use minikube for the kubernetes cluster. And from my point of view the error is not related to the restart. The error mesaage
Message : ERROR: column "expiration_timestamp" of relation "edc_edr_cache" already exists
The message indicates an error in the flyway setup.

@hemantxpatel
Copy link
Contributor

Hi @oliverbusch , this issue is best suited for tractusx-edc. We don't configure anything related to flyway. DB Migration scripts are part of EDC internally and we don't have any control / configurations on it.
I found a similar old issue related to EDR eclipse-tractusx/tractusx-edc#792

@oliverbusch
Copy link
Author

Ok, I will monitor eclipse-tractusx/tractusx-edc#792.

@hemantxpatel hemantxpatel closed this as not planned Won't fix, can't repro, duplicate, stale Jun 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants