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

set db version after full import is complete #4626

Merged
merged 3 commits into from
Jul 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@
import java.util.UUID;
import java.util.stream.Stream;

/**
* TODO Introduce a locking mechanism so that no DB operation is allowed when automatic migration is
* running
*/
public interface JobPersistence {

Job getJob(long jobId) throws IOException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,7 @@ public ImportRead importData(File archive) {
// 1. Unzip source
Archives.extractArchive(archive.toPath(), sourceRoot);

// 2. Set DB version
LOGGER.info("Setting the DB Airbyte version to : " + targetVersion);
postgresPersistence.setVersion(targetVersion);

// 3. dry run
// 2. dry run
try {
checkImport(sourceRoot);
} catch (Exception e) {
Expand All @@ -130,11 +126,18 @@ public ImportRead importData(File archive) {
throw e;
}

// 4. Import Postgres content
// 3. Import Postgres content
importDatabaseFromArchive(sourceRoot, targetVersion);

// 5. Import Configs
// 4. Import Configs
importConfigsFromArchive(sourceRoot, false);

// 5. Set DB version
LOGGER.info("Setting the DB Airbyte version to : " + targetVersion);
postgresPersistence.setVersion(targetVersion);

// 6. check db version
checkDBVersion(targetVersion);
result = new ImportRead().status(StatusEnum.SUCCEEDED);
} finally {
FileUtils.deleteDirectory(sourceRoot.toFile());
Expand Down Expand Up @@ -164,7 +167,6 @@ private void checkImport(Path tempFolder) throws IOException, JsonValidationExce
"Please upgrade your Airbyte Archive, see more at https://docs.airbyte.io/tutorials/upgrading-airbyte\n",
importVersion, targetVersion));
}
checkDBVersion(targetVersion);
importConfigsFromArchive(tempFolder, true);
}

Expand Down
4 changes: 4 additions & 0 deletions airbyte-server/src/main/java/io/airbyte/server/ServerApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,10 @@ public static void main(String[] args) throws Exception {
}
}

/**
* Ideally when automatic migration runs, we should make sure that we acquire a lock on database and
* no other operation is allowed
*/
private static void runAutomaticMigration(ConfigRepository configRepository,
JobPersistence jobPersistence,
String airbyteVersion,
Expand Down