Permalink
Please sign in to comment.
Showing
with
1,495 additions
and 45 deletions.
- +40 −1 MIGRATION.md
- +7 −0 build.sbt
- +5 −0 core/src/main/resources/application.conf
- +2 −1 core/src/main/scala/cromwell/core/simpleton/WdlValueSimpleton.scala
- +13 −0 database/core/src/main/scala/cromwell/database/core/SqlConfiguration.scala
- +2 −0 database/migration/src/main/resources/changelog.xml
- +92 −0 database/migration/src/main/resources/changesets/metadata_migration.xml
- +41 −0 ...migration/src/main/resources/changesets/migration/metadata/CreateAndLoadTmpExecutionMigration.sql
- +11 −0 database/migration/src/main/resources/changesets/migration/metadata/CreateTmpSymbolTable.sql
- +38 −0 database/migration/src/main/resources/changesets/migration/metadata/ExecutionInfoTableMigration.sql
- +34 −0 database/migration/src/main/resources/changesets/migration/metadata/LoadCallOutputSymbols.sql
- +26 −0 database/migration/src/main/resources/changesets/migration/metadata/LoadInputSymbols.sql
- +19 −0 database/migration/src/main/resources/changesets/migration/metadata/LoadWorkflowOutputSymbols.sql
- +22 −0 ...se/migration/src/main/resources/changesets/migration/metadata/RuntimeAttributesTableMigration.sql
- +47 −0 ...migration/src/main/resources/changesets/migration/metadata/WorkflowExecutionAuxTableMigration.sql
- +42 −0 database/migration/src/main/resources/changesets/standardize_column_names.xml
- +27 −0 database/migration/src/main/scala/cromwell/database/migration/WdlTransformation.scala
- +31 −0 database/migration/src/main/scala/cromwell/database/migration/metadata/MetadataCustomSql.scala
- +249 −0 ...migration/src/main/scala/cromwell/database/migration/metadata/table/ExecutionTableMigration.scala
- +62 −0 ...ration/src/main/scala/cromwell/database/migration/metadata/table/FailureEventTableMigration.scala
- +37 −0 ...ll/database/migration/metadata/table/executionevent/ExecutionEventTableDescriptionMigration.scala
- +38 −0 ...a/cromwell/database/migration/metadata/table/executionevent/ExecutionEventTableEndMigration.scala
- +37 −0 ...cromwell/database/migration/metadata/table/executionevent/ExecutionEventTableStartMigration.scala
- +34 −0 ...main/scala/cromwell/database/migration/metadata/table/symbol/CallOutputSymbolTableMigration.scala
- +38 −0 .../src/main/scala/cromwell/database/migration/metadata/table/symbol/InputSymbolTableMigration.scala
- +117 −0 ...igration/src/main/scala/cromwell/database/migration/metadata/table/symbol/MetadataStatement.scala
- +21 −0 ...e/migration/src/main/scala/cromwell/database/migration/metadata/table/symbol/QueryPaginator.scala
- +8 −0 ...igration/src/main/scala/cromwell/database/migration/metadata/table/symbol/ResultSetIterator.scala
- +195 −0 ...ation/src/main/scala/cromwell/database/migration/metadata/table/symbol/SymbolTableMigration.scala
- +22 −0 .../scala/cromwell/database/migration/metadata/table/symbol/WorkflowOutputSymbolTableMigration.scala
- +112 −0 ...romwell/database/migration/metadata/table/workflowexecution/WorkflowExecutionTableMigration.scala
- +4 −25 ...gration/src/main/scala/cromwell/database/migration/restart/table/JobStoreSimpletonMigration.scala
- +1 −1 database/sql/src/main/scala/cromwell/database/slick/tables/CallCachingResultMetaInfoComponent.scala
- +1 −1 database/sql/src/main/scala/cromwell/database/slick/tables/JobStoreComponent.scala
- +3 −3 database/sql/src/main/scala/cromwell/database/slick/tables/MetadataComponent.scala
- +1 −1 database/sql/src/main/scala/cromwell/database/slick/tables/WorkflowStoreComponent.scala
- +1 −7 database/sql/src/main/scala/cromwell/database/sql/SqlDatabase.scala
- +4 −2 project/Dependencies.scala
- +5 −0 project/Settings.scala
- +2 −1 services/src/main/scala/cromwell/services/ServicesStore.scala
- +2 −1 services/src/test/scala/cromwell/services/ServicesStoreSpec.scala
- +2 −1 services/src/test/scala/cromwell/services/metadata/impl/MetadataDatabaseAccessSpec.scala
41
MIGRATION.md
| @@ -0,0 +1,13 @@ | ||
| +package cromwell.database.core | ||
| + | ||
| +import com.typesafe.config.ConfigFactory | ||
| +import lenthall.config.ScalaConfig._ | ||
| + | ||
| +object SqlConfiguration { | ||
| + lazy val rootConfig = ConfigFactory.load() | ||
| + private lazy val rootDatabaseConfig = rootConfig.getConfig("database") | ||
| + private lazy val databaseConfigName = rootDatabaseConfig.getStringOption("config") | ||
| + lazy val defaultDatabaseConfig = databaseConfigName.map(getDatabaseConfig).getOrElse(rootDatabaseConfig) | ||
| + | ||
| + def getDatabaseConfig(path: String) = rootDatabaseConfig.getConfig(path) | ||
| +} |
| @@ -0,0 +1,92 @@ | ||
| +<?xml version="1.0" encoding="UTF-8" standalone="no"?> | ||
| +<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog" | ||
| + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
| + xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.3.xsd"> | ||
| + | ||
| + <changeSet dbms="mysql" author="tjeandet" id="setup_metadata_migration"> | ||
| + <!-- Temporary table containing all collectors IDs --> | ||
| + <sqlFile relativeToChangelogFile="true" path="migration/metadata/CreateAndLoadTmpExecutionMigration.sql" /> | ||
| + </changeSet> | ||
| + | ||
| + <!--Symbol Table--> | ||
| + <!--Input Symbol Table--> | ||
| + <changeSet dbms="mysql" id="create_tmp_symbol_for_inputs" author="tjeandet"> | ||
| + <sqlFile relativeToChangelogFile="true" path="migration/metadata/CreateTmpSymbolTable.sql" /> | ||
| + </changeSet> | ||
| + <changeSet dbms="mysql" id="load_tmp_symbol_for_inputs" author="tjeandet"> | ||
| + <sqlFile relativeToChangelogFile="true" path="migration/metadata/LoadInputSymbols.sql" /> | ||
| + </changeSet> | ||
| + <changeSet dbms="mysql" author="tjeandet" id="input_symbol_table_migration"> | ||
| + <customChange class="cromwell.database.migration.metadata.table.symbol.InputSymbolTableMigration" /> | ||
| + <dropTable tableName="TMP_SYMBOL" /> | ||
| + </changeSet> | ||
| + | ||
| + <!--Call Output Symbol Table--> | ||
| + <changeSet dbms="mysql" id="create_tmp_symbol_for_call_outputs" author="tjeandet"> | ||
| + <sqlFile relativeToChangelogFile="true" path="migration/metadata/CreateTmpSymbolTable.sql" /> | ||
| + </changeSet> | ||
| + <changeSet dbms="mysql" id="load_tmp_symbol_for_call_outputs" author="tjeandet"> | ||
| + <sqlFile relativeToChangelogFile="true" path="migration/metadata/LoadCallOutputSymbols.sql" /> | ||
| + </changeSet> | ||
| + <changeSet dbms="mysql" author="tjeandet" id="call_output_symbol_table_migration"> | ||
| + <customChange class="cromwell.database.migration.metadata.table.symbol.CallOutputSymbolTableMigration" /> | ||
| + <dropTable tableName="TMP_SYMBOL" /> | ||
| + </changeSet> | ||
| + | ||
| + <!--Workflow Output Symbol Table--> | ||
| + <changeSet dbms="mysql" id="create_tmp_symbol_for_workflow_outputs" author="tjeandet"> | ||
| + <sqlFile relativeToChangelogFile="true" path="migration/metadata/CreateTmpSymbolTable.sql" /> | ||
| + </changeSet> | ||
| + <changeSet dbms="mysql" id="load_tmp_symbol_for_workflow_outputs" author="tjeandet"> | ||
| + <sqlFile relativeToChangelogFile="true" path="migration/metadata/LoadWorkflowOutputSymbols.sql" /> | ||
| + </changeSet> | ||
| + <changeSet dbms="mysql" author="tjeandet" id="workflow_output_symbol_table_migration"> | ||
| + <customChange class="cromwell.database.migration.metadata.table.symbol.WorkflowOutputSymbolTableMigration" /> | ||
| + <dropTable tableName="TMP_SYMBOL" /> | ||
| + </changeSet> | ||
| + | ||
| + <!--Workflow Execution Table--> | ||
| + <changeSet dbms="mysql" author="tjeandet" id="workflow_execution_table_migration"> | ||
| + <customChange class="cromwell.database.migration.metadata.table.workflowexecution.WorkflowExecutionTableMigration" /> | ||
| + </changeSet> | ||
| + | ||
| + <!--Workflow Execution Aux Table--> | ||
| + <changeSet dbms="mysql" author="tjeandet" id="workflow_execution_aux_table_migration"> | ||
| + <sqlFile relativeToChangelogFile="true" path="migration/metadata/WorkflowExecutionAuxTableMigration.sql" /> | ||
| + </changeSet> | ||
| + | ||
| + <!--Execution Table--> | ||
| + <changeSet dbms="mysql" author="tjeandet" id="execution_table_migration"> | ||
| + <customChange class="cromwell.database.migration.metadata.table.ExecutionTableMigration" /> | ||
| + </changeSet> | ||
| + | ||
| + <!--Execution Event Table--> | ||
| + <changeSet dbms="mysql" author="tjeandet" id="execution_event_table_migration_start"> | ||
| + <customChange class="cromwell.database.migration.metadata.table.executionevent.ExecutionEventTableStartMigration" /> | ||
| + </changeSet> | ||
| + <changeSet dbms="mysql" author="tjeandet" id="execution_event_table_migration_end"> | ||
| + <customChange class="cromwell.database.migration.metadata.table.executionevent.ExecutionEventTableEndMigration" /> | ||
| + </changeSet> | ||
| + <changeSet dbms="mysql" author="tjeandet" id="execution_event_table_migration_description"> | ||
| + <customChange class="cromwell.database.migration.metadata.table.executionevent.ExecutionEventTableDescriptionMigration" /> | ||
| + </changeSet> | ||
| + | ||
| + <!--Execution Info Table--> | ||
| + <changeSet dbms="mysql" author="tjeandet" id="execution_info_table_migration"> | ||
| + <sqlFile relativeToChangelogFile="true" path="migration/metadata/ExecutionInfoTableMigration.sql" /> | ||
| + </changeSet> | ||
| + | ||
| + <!--Failure Event Table--> | ||
| + <changeSet dbms="mysql" author="tjeandet" id="failure_event_table_migration"> | ||
| + <customChange class="cromwell.database.migration.metadata.table.FailureEventTableMigration" /> | ||
| + </changeSet> | ||
| + | ||
| + <!--Runtime Attributes Table--> | ||
| + <changeSet dbms="mysql" author="tjeandet" id="runtime_attributes_table_migration"> | ||
| + <sqlFile relativeToChangelogFile="true" path="migration/metadata/RuntimeAttributesTableMigration.sql" /> | ||
| + </changeSet> | ||
| + | ||
| + <changeSet dbms="mysql" author="tjeandet" id="cleanup_metadata_migration"> | ||
| + <dropTable tableName="TMP_EXECUTION_MIGRATION" /> | ||
| + </changeSet> | ||
| +</databaseChangeLog> |
| @@ -0,0 +1,41 @@ | ||
| +CREATE TABLE TMP_EXECUTION_MIGRATION LIKE EXECUTION; | ||
| + | ||
| +INSERT INTO TMP_EXECUTION_MIGRATION ( | ||
| + EXECUTION_ID, | ||
| + WORKFLOW_EXECUTION_ID, | ||
| + RESULTS_CLONED_FROM, | ||
| + CALL_FQN, | ||
| + STATUS, | ||
| + IDX, | ||
| + RC, | ||
| + START_DT, | ||
| + END_DT, | ||
| + ALLOWS_RESULT_REUSE, | ||
| + DOCKER_IMAGE_HASH, | ||
| + EXECUTION_HASH, | ||
| + ATTEMPT, | ||
| + BACKEND_TYPE | ||
| +) | ||
| + SELECT | ||
| + EXECUTION_ID, | ||
| + WORKFLOW_EXECUTION_ID, | ||
| + RESULTS_CLONED_FROM, | ||
| + CALL_FQN, | ||
| + STATUS, | ||
| + IDX, | ||
| + RC, | ||
| + START_DT, | ||
| + END_DT, | ||
| + ALLOWS_RESULT_REUSE, | ||
| + DOCKER_IMAGE_HASH, | ||
| + EXECUTION_HASH, | ||
| + ATTEMPT, | ||
| + BACKEND_TYPE | ||
| + FROM EXECUTION e | ||
| + WHERE e.CALL_FQN NOT LIKE '%$%' AND -- filter out scatters | ||
| + NOT (e.IDX = -1 AND EXISTS ( -- filter out collectors | ||
| + SELECT 1 FROM EXECUTION e2 WHERE | ||
| + e2.WORKFLOW_EXECUTION_ID = e.WORKFLOW_EXECUTION_ID AND | ||
| + e2.CALL_FQN = e.CALL_FQN AND | ||
| + e2.IDX != -1) | ||
| + ); |
| @@ -0,0 +1,11 @@ | ||
| +CREATE TABLE TMP_SYMBOL | ||
| +( | ||
| + TMP_SYMBOL_ID INT PRIMARY KEY NOT NULL AUTO_INCREMENT, | ||
| + WORKFLOW_EXECUTION_UUID VARCHAR(100) NOT NULL, | ||
| + SYMBOL_NAME VARCHAR(100), | ||
| + SYMBOL_SCOPE VARCHAR(255), | ||
| + SYMBOL_INDEX INT, | ||
| + SYMBOL_ATTEMPT INT, | ||
| + WDL_VALUE LONGTEXT, | ||
| + WDL_TYPE VARCHAR(100) | ||
| +); |
| @@ -0,0 +1,38 @@ | ||
| +INSERT INTO METADATA_JOURNAL ( | ||
| + WORKFLOW_EXECUTION_UUID, | ||
| + METADATA_KEY, | ||
| + CALL_FQN, | ||
| + JOB_SCATTER_INDEX, | ||
| + JOB_RETRY_ATTEMPT, | ||
| + METADATA_VALUE, | ||
| + METADATA_VALUE_TYPE, | ||
| + METADATA_TIMESTAMP | ||
| +) | ||
| + SELECT | ||
| + WORKFLOW_EXECUTION_UUID, | ||
| + CASE ei.INFO_KEY | ||
| + WHEN '$log_stdout' THEN 'stdout' | ||
| + WHEN '$log_stderr' THEN 'stderr' | ||
| + WHEN 'JES_RUN_ID' THEN 'jobId' | ||
| + WHEN 'JES_STATUS' THEN 'backendStatus' | ||
| + WHEN 'SGE_JOB_NUMBER' THEN 'jobNumber' | ||
| + WHEN 'LSF_JOB_NUMBER' THEN 'jobNumber' | ||
| + ELSE | ||
| + IF(ei.INFO_KEY LIKE '$log_%', -- backend log | ||
| + CONCAT( | ||
| + 'backendLogs:', -- prepend metadata prefix | ||
| + SUBSTRING(ei.INFO_KEY, 6, LENGTH(ei.INFO_KEY) - 5) -- remove $log_ prefix from the key | ||
| + ), | ||
| + ei.INFO_KEY -- Just put the key otherwise | ||
| + ) END, | ||
| + CALL_FQN, | ||
| + IDX, | ||
| + ATTEMPT, | ||
| + ei.INFO_VALUE, | ||
| + 'string', | ||
| + NOW() | ||
| + FROM EXECUTION_INFO ei | ||
| + LEFT JOIN TMP_EXECUTION_MIGRATION e ON ei.EXECUTION_ID = e.EXECUTION_ID | ||
| + JOIN WORKFLOW_EXECUTION we ON we.WORKFLOW_EXECUTION_ID = e.WORKFLOW_EXECUTION_ID | ||
| + WHERE | ||
| + ei.INFO_VALUE IS NOT NULL; |
| @@ -0,0 +1,34 @@ | ||
| +INSERT INTO TMP_SYMBOL ( | ||
| + WORKFLOW_EXECUTION_UUID, | ||
| + SYMBOL_NAME, | ||
| + SYMBOL_SCOPE, | ||
| + SYMBOL_INDEX, | ||
| + SYMBOL_ATTEMPT, | ||
| + WDL_VALUE, | ||
| + WDL_TYPE | ||
| +) | ||
| + SELECT | ||
| + WORKFLOW_EXECUTION_UUID, | ||
| + s.NAME, | ||
| + e.CALL_FQN, | ||
| + e.IDX, | ||
| + e.ATTEMPT, | ||
| + s.WDL_VALUE, | ||
| + s.WDL_TYPE | ||
| + FROM SYMBOL s | ||
| + JOIN WORKFLOW_EXECUTION we ON | ||
| + we.WORKFLOW_EXECUTION_ID = s.WORKFLOW_EXECUTION_ID | ||
| + JOIN TMP_EXECUTION_MIGRATION e ON | ||
| + e.CALL_FQN = s.SCOPE AND | ||
| + e.WORKFLOW_EXECUTION_ID = s.WORKFLOW_EXECUTION_ID AND | ||
| + s.`INDEX` = e.IDX | ||
| + WHERE | ||
| + s.IO = 'OUTPUT' AND | ||
| + NOT EXISTS ( -- filter out earlier attempts | ||
| + SELECT 1 | ||
| + FROM TMP_EXECUTION_MIGRATION e3 | ||
| + WHERE | ||
| + e3.WORKFLOW_EXECUTION_ID = e.WORKFLOW_EXECUTION_ID AND | ||
| + e3.CALL_FQN = e.CALL_FQN AND | ||
| + e3.IDX = e.IDX AND | ||
| + e3.ATTEMPT > e.ATTEMPT); |
| @@ -0,0 +1,26 @@ | ||
| +INSERT INTO TMP_SYMBOL ( | ||
| + WORKFLOW_EXECUTION_UUID, | ||
| + SYMBOL_NAME, | ||
| + SYMBOL_SCOPE, | ||
| + SYMBOL_INDEX, | ||
| + SYMBOL_ATTEMPT, | ||
| + WDL_VALUE, | ||
| + WDL_TYPE | ||
| +) | ||
| + SELECT | ||
| + WORKFLOW_EXECUTION_UUID, | ||
| + s.NAME, | ||
| + s.SCOPE, | ||
| + e.IDX, | ||
| + e.ATTEMPT, | ||
| + s.WDL_VALUE, | ||
| + s.WDL_TYPE | ||
| + FROM SYMBOL s | ||
| + JOIN WORKFLOW_EXECUTION we ON | ||
| + we.WORKFLOW_EXECUTION_ID = s.WORKFLOW_EXECUTION_ID | ||
| + LEFT JOIN TMP_EXECUTION_MIGRATION e ON | ||
| + e.CALL_FQN = s.SCOPE AND | ||
| + e.WORKFLOW_EXECUTION_ID = s.WORKFLOW_EXECUTION_ID | ||
| + -- Don't join on index here because inputs have index null (-1), but we want to duplicate them as many times as there are indices for a given execution | ||
| + WHERE | ||
| + s.IO = 'INPUT'; |
| @@ -0,0 +1,19 @@ | ||
| +INSERT INTO TMP_SYMBOL ( | ||
| + WORKFLOW_EXECUTION_UUID, | ||
| + SYMBOL_NAME, | ||
| + SYMBOL_SCOPE, | ||
| + WDL_VALUE, | ||
| + WDL_TYPE | ||
| +) | ||
| + SELECT | ||
| + WORKFLOW_EXECUTION_UUID, | ||
| + s.NAME, | ||
| + s.SCOPE, | ||
| + s.WDL_VALUE, | ||
| + s.WDL_TYPE | ||
| + FROM SYMBOL s | ||
| + JOIN WORKFLOW_EXECUTION we ON | ||
| + we.WORKFLOW_EXECUTION_ID = s.WORKFLOW_EXECUTION_ID | ||
| + WHERE | ||
| + s.IO = 'OUTPUT' AND | ||
| + s.REPORTABLE_RESULT = 1; |
Oops, something went wrong.
0 comments on commit
74c058d