launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #30400
[Merge] ~cjwatson/launchpad:stagingsetup-silence-errors into launchpad:master
Colin Watson has proposed merging ~cjwatson/launchpad:stagingsetup-silence-errors into launchpad:master.
Commit message:
Silence an error from "make -C database/replication stagingsetup"
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/449195
The weekly staging restore process currently includes the following output:
Setting feature flags
psql -d lpmain_staging -c "INSERT INTO featureflag (flag, scope, priority, value) VALUES ('profiling.enabled', 'team:launchpad', 0, 'on')"
INSERT 0 1
psql -d lpmain_staging -c "INSERT INTO featureflag (flag, scope, priority, value) VALUES ('librarian.swift.enabled', 'default', 0, 'on')"
ERROR: duplicate key value violates unique constraint "feature_flag_pkey"
DETAIL: Key (scope, flag)=(default, librarian.swift.enabled) already exists.
Makefile:57: recipe for target 'stagingsetup' failed
make: [stagingsetup] Error 1 (ignored)
This is in fact harmless (the leading `-` on those lines means that we carry on anyway), but it confused me briefly. I think it's a little neater to use `ON CONFLICT DO NOTHING` to ensure that the statement succeeds even if an identical feature rule already exists in the data synced from production.
--
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:stagingsetup-silence-errors into launchpad:master.
diff --git a/database/replication/Makefile b/database/replication/Makefile
index ab48761..8f63dc0 100644
--- a/database/replication/Makefile
+++ b/database/replication/Makefile
@@ -92,8 +92,8 @@ stagingsetup:
LPCONFIG=${STAGING_CONFIG} ${SHHH} ../schema/security.py \
--log-file=INFO:${STAGING_LOGDIR}/dbupgrade.log
@echo Setting feature flags
- -psql -d lpmain_staging -c "INSERT INTO featureflag (flag, scope, priority, value) VALUES ('profiling.enabled', 'team:launchpad', 0, 'on')"
- -psql -d lpmain_staging -c "INSERT INTO featureflag (flag, scope, priority, value) VALUES ('librarian.swift.enabled', 'default', 0, 'on')"
+ psql -d lpmain_staging -c "INSERT INTO featureflag (flag, scope, priority, value) VALUES ('profiling.enabled', 'team:launchpad', 0, 'on') ON CONFLICT DO NOTHING"
+ psql -d lpmain_staging -c "INSERT INTO featureflag (flag, scope, priority, value) VALUES ('librarian.swift.enabled', 'default', 0, 'on') ON CONFLICT DO NOTHING"
${STAGING_PGBOUNCER} -c 'ENABLE launchpad_staging'
${STAGING_PGBOUNCER} -c 'ENABLE launchpad_staging_slave'