Slide 1

Slide 1 text

Continuous Deployment and Schema Evolution in SQL Databases

Slide 2

Slide 2 text

Michael de Jong @java_devver

Slide 3

Slide 3 text

Arie van Deursen @avandeursen

Slide 4

Slide 4 text

But besides being a student… … I’m also a practitioner

Slide 5

Slide 5 text

My long-time interest: How do you deploy a new version of a web service without downtime?

Slide 6

Slide 6 text

SQL Databases!

Slide 7

Slide 7 text

Relevance Continuous Deployment rapidly delivers business value. It is important to remove any impediments to its adoption.

Slide 8

Slide 8 text

Why is it so difficult?

Slide 9

Slide 9 text

Reason 1: DDL statements Statements which change the structure of the database (tables, columns, indices, foreign keys, etc)

Slide 10

Slide 10 text

They prevent other queries from being executed!

Slide 11

Slide 11 text

Reason 2: Mixed-State During deploying, two different versions might be accessing the same database

Slide 12

Slide 12 text

Reason 3: Referential Integrity None of the surveyed tools and approaches fully support foreign keys.

Slide 13

Slide 13 text

Our proposal

Slide 14

Slide 14 text

changelog.addChangeSet(“Add referral column to customers table”, addColumn(“customers”, “referred_by”, int()), addForeignKey(“customers”, “referred_by”) .referencing(“customers”, “id”)); Defining changes

Slide 15

Slide 15 text

Defining changes 82fba53 - CURRENT STATE 2ef5c1a 80bfa11 - FINAL STATE ADD COLUMN ADD FOREIGN KEY

Slide 16

Slide 16 text

Evolving the database schema movies rentals customers

Slide 17

Slide 17 text

Evolving the database schema movies rentals customers customers*

Slide 18

Slide 18 text

movies rentals customers customers* rentals* Evolving the database schema

Slide 19

Slide 19 text

movies rentals customers customers* rentals* Evolving the database schema

Slide 20

Slide 20 text

movies rentals customers customers* rentals* Evolving the database schema

Slide 21

Slide 21 text

movies rentals customers customers* rentals* Evolving the database schema

Slide 22

Slide 22 text

Accessing the database movies rentals customers customers* rentals* Schema: 82fba53

Slide 23

Slide 23 text

movies rentals customers customers* rentals* Schema: 82fba53 Schema: 80bfa11 Accessing the database

Slide 24

Slide 24 text

Application Driver Accessing the database

Slide 25

Slide 25 text

Application Wrapper Driver Accessing the database

Slide 26

Slide 26 text

DriverManager.getConnection( “jdbc:postgresql://localhost:5432/database”, “username”, “password”); DriverManager.getConnection( “jdbc:quantumdb:postgresql://localhost:5432/database?version=80bfa11”, “username”, “password”); Accessing the database

Slide 27

Slide 27 text

SELECT * FROM rentals WHERE customer_id = 2372 AND return_date < NOW() AND returned = false; SELECT * FROM rentals* WHERE customer_id = 2372 AND return_date < NOW() AND returned = false; Accessing the database

Slide 28

Slide 28 text

Dropping a schema movies rentals customers customers* rentals*

Slide 29

Slide 29 text

movies rentals customers customers* rentals* Dropping a schema

Slide 30

Slide 30 text

movies customers* rentals* Dropping a schema

Slide 31

Slide 31 text

movies customers* rentals* Schema: 80bfa11 Dropping a schema

Slide 32

Slide 32 text

Early evaluation

Slide 33

Slide 33 text

#1 Blocking DDL statements Avoids using blocking DDL statements, since all affected tables are recreated from scratch.

Slide 34

Slide 34 text

#2 Mixed-State Tables from other database schemas are hidden from the web service.

Slide 35

Slide 35 text

#3 Referential Integrity Our approach maintains Referential Integrity during schema evolution.

Slide 36

Slide 36 text

Limitations

Slide 37

Slide 37 text

Supported Databases

Slide 38

Slide 38 text

Supported Operations SUPPORTED ADD COLUMN ALTER COLUMN DROP COLUMN CREATE TABLE COPY TABLE RENAME TABLE DROP TABLE ADD FOREIGN KEY DROP FOREIGN KEY NOT YET SUPPORTED CREATE INDEX DROP INDEX ADD CHECK CONSTRAINT DROP CHECK CONSTRAINT DECOMPOSE TABLE * JOIN TABLE * MERGE TABLE * PARTITION TABLE * * Update Rewriting and Integrity Constraint Maintenance in a Schema Evolution Support System: PRISM++, C. A. Curino et al. (2010)

Slide 39

Slide 39 text

I/O Limitations Copying data is limited by disk I/O. We could actively throttle this based on some metric.

Slide 40

Slide 40 text

Novelty • Support complex schema changes on multiple tables. • Maintain referential integrity. • Multiple database schemas can be used in parallel.

Slide 41

Slide 41 text

QuantumDB blog.minicom.nl - @java_devver