Slide 1

Slide 1 text

Zero-downtime Postgres migrations - the hard parts @ChrisSinjo

Slide 2

Slide 2 text

Apps change frequently

Slide 3

Slide 3 text

Many apps can’t take downtime

Slide 4

Slide 4 text

The easy parts

Slide 5

Slide 5 text

- Multiple app versions - Fast DDL statements

Slide 6

Slide 6 text

Fine, until it’s not

Slide 7

Slide 7 text

We took downtime :(

Slide 8

Slide 8 text

Let’s talk about queues

Slide 9

Slide 9 text

-- Slow query (AccessShare) SELECT DISTINCT(customer_id) FROM payments; -- Forces this to queue (AccessExclusive) ALTER TABLE payments ADD COLUMN refunded boolean; -- Which blocks these (AccessShare) SELECT * FROM payments WHERE id = 123;

Slide 10

Slide 10 text

- Kill slow queries - Set lock_timeout low - Enable log_lock_waits

Slide 11

Slide 11 text

We blogged about this
 two weeks ago I’ll tweet the link from @ChrisSinjo