← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~cjwatson/launchpad/safer-staging-restore into lp:launchpad

 

Colin Watson has proposed merging lp:~cjwatson/launchpad/safer-staging-restore into lp:launchpad.

Commit message:
Ensure that the production dump is usable before destroying staging.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/safer-staging-restore/+merge/305007

Ensure that the production dump is usable before destroying staging.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~cjwatson/launchpad/safer-staging-restore into lp:launchpad.
=== modified file 'database/replication/Makefile'
--- database/replication/Makefile	2015-12-07 09:04:42 +0000
+++ database/replication/Makefile	2016-09-06 14:18:14 +0000
@@ -54,6 +54,11 @@
 # place.
 stagingsetup: DUMPLIST:=$(shell tempfile --suffix=.lst --prefix=lpstag)
 stagingsetup:
+	# List the dump first to make sure it is usable before destroying
+	# anything.
+	pg_restore --list ${STAGING_DUMP} | grep -v 'TRIGGER public _sl_' \
+	    > ${DUMPLIST}
+
 	# Deny new connections to the main DBs and kill any leftovers.
 	${STAGING_PGBOUNCER} -c 'DISABLE launchpad_staging'
 	${STAGING_PGBOUNCER} -c 'DISABLE launchpad_staging_slave'
@@ -74,8 +79,6 @@
 	# Restore the database. We need to restore permissions, despite
 	# later running security.py, to pull in permissions granted on
 	# production to users not maintained by security.py.
-	pg_restore --list ${STAGING_DUMP} | grep -v 'TRIGGER public _sl_' \
-	    > ${DUMPLIST}
 	cat ${STAGING_DUMP} \
 	    | ./walblock.py -n 5000 -d /var/lib/postgresql/9.3/staging/pg_xlog \
 	    | pg_restore --dbname=lpmain_staging --no-owner ${EXIT_ON_ERROR} \


Follow ups