Skip to content

Commit

Permalink
spacemanager: Reorder liquibase changesets to make updates faster
Browse files Browse the repository at this point in the history
If we drop and delete stuff before doing things that trigger
a table rewrite, then upgrading to 2.8 will be faster.

Target: trunk
Require-notes: no
Require-book: no
Acked-by: Paul Millar <paul.millar@desy.de>
Patch: http://rb.dcache.org/r/6481/
  • Loading branch information
gbehrmann committed Jan 28, 2014
1 parent c6ea3fb commit 940254b
Showing 1 changed file with 45 additions and 43 deletions.
Expand Up @@ -196,19 +196,7 @@
</rollback>
</changeSet>

<changeSet id="5" author="behrmann">
<comment>Add non-null constraints to required fields</comment>
<addNotNullConstraint tableName="srmlinkgroup" columnName="freespaceinbytes"/>
<addNotNullConstraint tableName="srmlinkgroup" columnName="reservedspaceinbytes"/>
<addNotNullConstraint tableName="srmspace" columnName="sizeinbytes"/>
<addNotNullConstraint tableName="srmspace" columnName="usedspaceinbytes"/>
<addNotNullConstraint tableName="srmspace" columnName="allocatedspaceinbytes"/>
<addNotNullConstraint tableName="srmspace" columnName="linkgroupid"/>
<addNotNullConstraint tableName="srmspace" columnName="state"/>
<addNotNullConstraint tableName="srmspacefile" columnName="sizeinbytes"/>
<addNotNullConstraint tableName="srmspacefile" columnName="spacereservationid"/>
<addNotNullConstraint tableName="srmspacefile" columnName="state"/>
</changeSet>
<!-- The above change sets correspond to the schema of space manager before dCache 2.8 -->

<changeSet id="6" author="behrmann">
<comment>Use auto-increment primary keys</comment>
Expand Down Expand Up @@ -258,6 +246,21 @@
</rollback>
</changeSet>

<changeSet id="14" author="behrmann">
<comment>Drop indexes on pnfspath column</comment>
<dropIndex tableName="srmspacefile" indexName="srmspacefile_pnfspath_idx"/>
<dropIndex tableName="srmspacefile" indexName="srmspacefile_pnfspath_state_idx"/>
<rollback>
<createIndex tableName="srmspacefile" indexName="srmspacefile_pnfspath_state_idx">
<column name="pnfspath"/>
<column name="state"/>
</createIndex>
<createIndex tableName="srmspacefile" indexName="srmspacefile_pnfspath_idx">
<column name="pnfspath"/>
</createIndex>
</rollback>
</changeSet>

<changeSet id="9" author="behrmann">
<comment>Drop index on pnfsid column</comment>
<dropIndex tableName="srmspacefile" indexName="srmspacefile_pnfsid_idx"/>
Expand All @@ -268,6 +271,18 @@
</rollback>
</changeSet>

<changeSet id="12" author="behrmann">
<comment>Remove deleted flushed files</comment>
<sql>DELETE FROM srmspacefile WHERE state = 3 AND deleted = 1</sql>
<rollback/>
</changeSet>

<changeSet id="15" author="behrmann">
<comment>Clear pnfspath on deleted, stored and flushed files</comment>
<sql>UPDATE srmspacefile SET pnfspath = NULL WHERE deleted = 1 OR state IN (2,3)</sql>
<rollback/>
</changeSet>

<changeSet id="10" author="behrmann">
<comment>Change pnfsid column to VARCHAR(36)</comment>
<modifyDataType tableName="srmspacefile" columnName="pnfsid" newDataType="varchar(36)"/>
Expand All @@ -281,41 +296,28 @@
<addUniqueConstraint tableName="srmspacefile" columnNames="pnfsid" constraintName="srmspacefile_pnfsid_unique"/>
</changeSet>

<changeSet id="12" author="behrmann">
<comment>Remove deleted flushed files</comment>
<sql>DELETE FROM srmspacefile WHERE state = 3 AND deleted = 1</sql>
<rollback/>
<changeSet id="16" author="behrmann">
<comment>Add unique constraint (and thus index) on pnfspath column</comment>
<addUniqueConstraint tableName="srmspacefile" columnNames="pnfspath" constraintName="srmspacefile_pnfspath_unique"/>
</changeSet>

<changeSet id="5" author="behrmann">
<comment>Add non-null constraints to required fields</comment>
<addNotNullConstraint tableName="srmlinkgroup" columnName="freespaceinbytes"/>
<addNotNullConstraint tableName="srmlinkgroup" columnName="reservedspaceinbytes"/>
<addNotNullConstraint tableName="srmspace" columnName="sizeinbytes"/>
<addNotNullConstraint tableName="srmspace" columnName="usedspaceinbytes"/>
<addNotNullConstraint tableName="srmspace" columnName="allocatedspaceinbytes"/>
<addNotNullConstraint tableName="srmspace" columnName="linkgroupid"/>
<addNotNullConstraint tableName="srmspace" columnName="state"/>
<addNotNullConstraint tableName="srmspacefile" columnName="sizeinbytes"/>
<addNotNullConstraint tableName="srmspacefile" columnName="spacereservationid"/>
<addNotNullConstraint tableName="srmspacefile" columnName="state"/>
</changeSet>

<changeSet id="13" author="behrmann">
<comment>Add not-null and uniqueness constraints to linkgroup name</comment>
<addNotNullConstraint tableName="srmlinkgroup" columnName="name"/>
<addUniqueConstraint tableName="srmlinkgroup" columnNames="name" constraintName="srmlinkgroup_name_unique"/>
</changeSet>

<changeSet id="14" author="behrmann">
<comment>Drop indexes on pnfspath column</comment>
<dropIndex tableName="srmspacefile" indexName="srmspacefile_pnfspath_idx"/>
<dropIndex tableName="srmspacefile" indexName="srmspacefile_pnfspath_state_idx"/>
<rollback>
<createIndex tableName="srmspacefile" indexName="srmspacefile_pnfspath_state_idx">
<column name="pnfspath"/>
<column name="state"/>
</createIndex>
<createIndex tableName="srmspacefile" indexName="srmspacefile_pnfspath_idx">
<column name="pnfspath"/>
</createIndex>
</rollback>
</changeSet>

<changeSet id="15" author="behrmann">
<comment>Clear pnfspath on deleted, stored and flushed files</comment>
<sql>UPDATE srmspacefile SET pnfspath = NULL WHERE deleted = 1 OR state IN (2,3)</sql>
<rollback/>
</changeSet>

<changeSet id="16" author="behrmann">
<comment>Add unique constraint (and thus index) on pnfspath column</comment>
<addUniqueConstraint tableName="srmspacefile" columnNames="pnfspath" constraintName="srmspacefile_pnfspath_unique"/>
</changeSet>
</databaseChangeLog>

0 comments on commit 940254b

Please sign in to comment.