[
https://issues.apache.org/jira/browse/TAJO-1109?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14205325#comment-14205325
]
ASF GitHub Bot commented on TAJO-1109:
--------------------------------------
Github user hyunsik commented on a diff in the pull request:
https://github.com/apache/tajo/pull/216#discussion_r20112082
--- Diff:
tajo-catalog/tajo-catalog-server/src/main/java/org/apache/tajo/catalog/store/AbstractDBStore.java
---
@@ -176,42 +202,47 @@ public Connection getConnection() {
return conn;
}
- private void verifySchemaVersion() throws CatalogException {
+ private int getSchemaVersion() {
Connection conn = null;
PreparedStatement pstmt = null;
ResultSet result = null;
+ int schemaVersion = -1;
+
+ String sql = "SELECT version FROM META";
+ if (LOG.isDebugEnabled()) {
+ LOG.debug(sql.toString());
+ }
try {
- String sql = "SELECT version FROM META";
- if (LOG.isDebugEnabled()) {
- LOG.debug(sql.toString());
- }
-
conn = getConnection();
pstmt = conn.prepareStatement(sql);
result = pstmt.executeQuery();
- boolean noVersion = !result.next();
-
- int schemaVersion = result.getInt(1);
- if (noVersion || schemaVersion != getDriverVersion()) {
- LOG.error(String.format("Catalog version (%d) and current driver
version (%d) are mismatch to each other",
- schemaVersion, getDriverVersion()));
-
LOG.error("=========================================================================");
- LOG.error("| Catalog Store Migration Is Needed
|");
-
LOG.error("=========================================================================");
- LOG.error("| You might downgrade or upgrade Apache Tajo.
Downgrading or upgrading |");
- LOG.error("| Tajo without migration process is only available in
some versions. |");
- LOG.error("| In order to learn how to migration Apache Tajo
instance, |");
- LOG.error("| please refer http://s.apache.org/0_8_migration.
|");
-
LOG.error("=========================================================================");
- throw new CatalogException("Migration Needed. Please refer
http://s.apache.org/0_8_migration.");
+ if (result.next()) {
+ schemaVersion = result.getInt("VERSION");
}
} catch (SQLException e) {
- throw new CatalogException(e);
+ throw new CatalogException(e.getMessage(), e);
} finally {
CatalogUtil.closeQuietly(pstmt, result);
}
+
+ return schemaVersion;
+ }
+
+ private void verifySchemaVersion() throws CatalogException {
+ int schemaVersion = -1;
+
+ schemaVersion = getSchemaVersion();
+
+ if (schemaVersion == -1 || schemaVersion != getDriverVersion()) {
+ LOG.info(String.format("Catalog version (%d) and current driver
version (%d) are mismatch to each other",
+ schemaVersion, getDriverVersion()));
+ LOG.info("It will start upgrade process on catalog stores.");
+
+ catalogSchemaManager.upgradeBaseSchema(getConnection(),
schemaVersion);
--- End diff --
I believe that ```tajo_dump``` approach is productive to us in terms of
development and more safe for upgrading.
With ```tajo_dump```, the instruction of Tajo migration is as follows:
1. execute ```tajo_dump``` to dump your all catalog information to **Tajo
DDL statements** as a plan text file (e.g., backup.sql).
2. create new database in your catalog store (PostgreSQL or MySQL) for
migration
3. change the catalog store config in ```catalog-site.xml``` in order to
use newly created database
4. restart a Tajo cluster
5. run ```tsql -f backup.sql``` to execute a sequence of **Tajo DDL
statements** from the backup.sql
This approach naturally allows users to keep original catalog tables
without additional database backup. Even if upgrade is failed, the original
catalogs would be safe.
Another motivation of ```tajo-dump``` approach allows us to change catalog
schemas without considering schema upgrades. Actually, our catalog is still
evolving rapidly. It may be important to us in this time.
This is my opinion. I'm open to any discussion.
Thank you for your work.
> Separate SQL Statements from Catalog Stores
> -------------------------------------------
>
> Key: TAJO-1109
> URL: https://issues.apache.org/jira/browse/TAJO-1109
> Project: Tajo
> Issue Type: Improvement
> Components: catalog
> Reporter: Jihun Kang
> Assignee: Jihun Kang
> Priority: Minor
> Fix For: 0.9.1
>
> Attachments: DBMSSchemaDefinition.xsd, derby.xml
>
>
> When developing the additional catalog stores for another database systems,
> it is needed to add additional sql statements such as triggers and indexes.
> These sql statements could increase the code size of catalog store, and when
> database schema has changed, it may affect the catalog store source codes. I
> feel that it is needed to separate the sql statements from the java source
> codes.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)