Skip to content
This repository has been archived by the owner on Dec 13, 2023. It is now read-only.

update flyway version #2065

Merged
merged 4 commits into from Apr 5, 2021
Merged

update flyway version #2065

merged 4 commits into from Apr 5, 2021

Conversation

michaelpaliy
Copy link
Contributor

@michaelpaliy michaelpaliy commented Feb 1, 2021

Hi,
Our conductor setup consists of multiple instances. If we start the instances simultaneously, sometimes we got the following error:

2021-02-01 12:42:08,339 [main] ERROR error migration DB
org.flywaydb.core.internal.dbsupport.FlywaySqlScriptException:
Script failed
-------------
SQL State  : 23505
Error Code : 0
Message    : ERROR: duplicate key value violates unique constraint "pg_type_typname_nsp_index"
  Detail: Key (typname, typnamespace)=(schema_version, 2200) already exists.
Line       : 17
Statement  : CREATE TABLE "public"."schema_version" (
    "installed_rank" INT NOT NULL,
    "version" VARCHAR(50),
    "description" VARCHAR(200) NOT NULL,
    "type" VARCHAR(20) NOT NULL,
    "script" VARCHAR(1000) NOT NULL,
    "checksum" INTEGER,
    "installed_by" VARCHAR(100) NOT NULL,
    "installed_on" TIMESTAMP NOT NULL DEFAULT now(),
    "execution_time" INTEGER NOT NULL,
    "success" BOOLEAN NOT NULL
) WITH (
  OIDS=FALSE
)

        at org.flywaydb.core.internal.dbsupport.SqlScript.execute(SqlScript.java:117)
        at org.flywaydb.core.internal.metadatatable.MetaDataTableImpl.createIfNotExists(MetaDataTableImpl.java:104)
        at org.flywaydb.core.internal.metadatatable.MetaDataTableImpl.lock(MetaDataTableImpl.java:111)
        at org.flywaydb.core.internal.command.DbMigrate$2.doInTransaction(DbMigrate.java:175)
        at org.flywaydb.core.internal.command.DbMigrate$2.doInTransaction(DbMigrate.java:173)
        at org.flywaydb.core.internal.util.jdbc.TransactionTemplate.execute(TransactionTemplate.java:72)
        at org.flywaydb.core.internal.command.DbMigrate.migrate(DbMigrate.java:173)
        at org.flywaydb.core.Flyway$1.execute(Flyway.java:959)
        at org.flywaydb.core.Flyway$1.execute(Flyway.java:917)
        at org.flywaydb.core.Flyway.execute(Flyway.java:1373)
        at org.flywaydb.core.Flyway.migrate(Flyway.java:917)
        at com.netflix.conductor.postgres.PostgresDataSourceProvider.flywayMigrate(PostgresDataSourceProvider.java:94)
        at com.netflix.conductor.postgres.PostgresDataSourceProvider.get(PostgresDataSourceProvider.java:43)
        at com.netflix.conductor.postgres.PostgresDataSourceProvider.get(PostgresDataSourceProvider.java:28)

This issue is related to flyway (conductor is using flyway:4.0.3, this issue is fixed in 5.1.0):
flyway/flyway#1067
flyway/flyway#1983

In this PR, I updated the flyway version to the latest one which solves this issue.

@apanicker-nflx
Copy link
Collaborator

@mactaggart @rickfish Could you please help with reviewing this PR.

@codecov
Copy link

codecov bot commented Feb 2, 2021

Codecov Report

Merging #2065 (5286140) into dev (f515e0c) will decrease coverage by 0.07%.
The diff coverage is 100.00%.

Impacted file tree graph

@@             Coverage Diff              @@
##                dev    #2065      +/-   ##
============================================
- Coverage     65.77%   65.69%   -0.08%     
+ Complexity     3969     3967       -2     
============================================
  Files           301      301              
  Lines         18601    18599       -2     
  Branches       1708     1708              
============================================
- Hits          12235    12219      -16     
- Misses         5521     5533      +12     
- Partials        845      847       +2     
Impacted Files Coverage Δ Complexity Δ
...om/netflix/conductor/mysql/MySQLConfiguration.java 100.00% <100.00%> (ø) 13.00 <1.00> (ø)
...tflix/conductor/mysql/MySQLDataSourceProvider.java 81.81% <100.00%> (+6.81%) 5.00 <0.00> (ø)
...flix/conductor/postgres/PostgresConfiguration.java 100.00% <100.00%> (ø) 13.00 <1.00> (ø)
...conductor/postgres/PostgresDataSourceProvider.java 82.22% <100.00%> (+6.66%) 5.00 <0.00> (ø)
...ductor/dao/cassandra/CassandraEventHandlerDAO.java 65.78% <0.00%> (-10.53%) 15.00% <0.00%> (ø%)
.../conductor/dao/cassandra/CassandraMetadataDAO.java 53.88% <0.00%> (-5.70%) 24.00% <0.00%> (-1.00%)
...e/execution/tasks/SystemTaskWorkerCoordinator.java 81.25% <0.00%> (-2.09%) 17.00% <0.00%> (-1.00%)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f515e0c...5286140. Read the comment docs.

@coveralls
Copy link

coveralls commented Feb 2, 2021

Pull Request Test Coverage Report for Build 5058

  • 17 of 17 (100.0%) changed or added relevant lines in 4 files are covered.
  • 2 unchanged lines in 1 file lost coverage.
  • Overall coverage increased (+0.02%) to 70.283%

Files with Coverage Reduction New Missed Lines %
cassandra-persistence/src/main/java/com/netflix/conductor/dao/cassandra/CassandraMetadataDAO.java 2 55.44%
Totals Coverage Status
Change from base Build 5047: 0.02%
Covered Lines: 13072
Relevant Lines: 18599

💛 - Coveralls

@rickfish
Copy link
Contributor

rickfish commented Feb 2, 2021

I am a couple of dev versions behind so maybe it is because of that but I made the same changes in the Postgres module and I get this error at startup (we have a schema named conductor-unita in our 'unit' database):

[ERROR] 2021-02-02 14:24:31,388 PostgresDataSourceProvider - error migration DB
org.flywaydb.core.api.FlywayException: Found non-empty schema(s) "conductor_unita" but no schema history table. Use baseline() or set baselineOnMigrate to true to initialize the schema history table.
at org.flywaydb.core.Flyway$1.execute(Flyway.java:196)

@michaelpaliy
Copy link
Contributor Author

michaelpaliy commented Feb 3, 2021

Hi @rickfish
Thanks for the review.
Flyway changed the default schema history table name from schema_version to flyway_schema_history.
So, it's not recognized your history table and you got an error.
I updated the configurations to use schema_version as default.
can you pls try to run it again with the new commit?

# Conflicts:
#	server/dependencies.lock
#	test-harness/dependencies.lock
@michaelpaliy
Copy link
Contributor Author

Hi @rickfish ,
Any update? Did you get a chance to look into it?

@michaelpaliy
Copy link
Contributor Author

Hi @apanicker-nflx / @aravindanr,
Could you pls review and merge this PR?
This issue blocking us, and force us to work with a forked repo.
We have a requirement to destroy and deploy new conductor clusters which consist of multiple instances,
When we deploy a new cluster with an empty database we get the following error:
ERROR: duplicate key value violates unique constraint "pg_type_typname_nsp_index"
This PR fixes this issue, by updating the flyway version (which causes this bug).

@apanicker-nflx apanicker-nflx merged commit dabbacc into Netflix:dev Apr 5, 2021
TwoUnderscorez pushed a commit to TwoUnderscorez/conductor that referenced this pull request Jul 23, 2021
* update flyway version

* set FLYWAY_TABLE_DEFAULT_VALUE to schema_history

* update flyway version

Co-authored-by: michaelpa <michael.paliy@niceactimize.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants