You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@gobblin.apache.org by ap...@apache.org on 2021/08/19 22:59:12 UTC

[gobblin] branch master updated: [GOBBLIN-1457] Fix service DB initialization when DB is not empty (#3371)

This is an automated email from the ASF dual-hosted git repository.

aplex pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/gobblin.git


The following commit(s) were added to refs/heads/master by this push:
     new 35f98f0  [GOBBLIN-1457] Fix service DB initialization when DB is not empty (#3371)
35f98f0 is described below

commit 35f98f02473e25c163837f3eb41753aa90f10cc9
Author: Alex Prokofiev <ap...@linkedin.com>
AuthorDate: Thu Aug 19 15:59:04 2021 -0700

    [GOBBLIN-1457] Fix service DB initialization when DB is not empty (#3371)
    
    By default, Flyway will throw an exception if the database is not
    empty and Flyway's own table is missing. Production Gobblin service
    DBs already have state tables in them, so migration didn't work.
    
    With this change, we ask Flyway to ignore existing tables when
    initializing new db.
---
 .../apache/gobblin/service/modules/db/ServiceDatabaseManager.java | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/gobblin-service/src/main/java/org/apache/gobblin/service/modules/db/ServiceDatabaseManager.java b/gobblin-service/src/main/java/org/apache/gobblin/service/modules/db/ServiceDatabaseManager.java
index da1ad05..e9896b0 100644
--- a/gobblin-service/src/main/java/org/apache/gobblin/service/modules/db/ServiceDatabaseManager.java
+++ b/gobblin-service/src/main/java/org/apache/gobblin/service/modules/db/ServiceDatabaseManager.java
@@ -49,7 +49,13 @@ public class ServiceDatabaseManager extends AbstractIdleService {
 
     Flyway flyway =
         Flyway.configure().locations("classpath:org/apache/gobblin/service/db/migration").failOnMissingLocations(true)
-            .dataSource(databaseProvider.getDatasource()).load();
+            .dataSource(databaseProvider.getDatasource())
+            // Existing GaaS DBs have state store tables.
+            // Flyway will refuse to use such non-empty DBs by default. With baselineOnMigrate(true), it should
+            // create new tables, while keeping old ones intact.
+            .baselineOnMigrate(true)
+            .baselineVersion("0")
+            .load();
 
     log.info("Ensuring service database is migrated to latest schema");
     // Start the migration