Merge ~cjwatson/launchpad:db-artifactory-publishing-columns-not-null into launchpad:db-devel

Proposed by Colin Watson
Status: Needs review
Proposed branch: ~cjwatson/launchpad:db-artifactory-publishing-columns-not-null
Merge into: launchpad:db-devel
Diff against target: 22 lines (+16/-0)
1 file modified
database/schema/patch-2211-08-0.sql (+16/-0)
Reviewer Review Type Date Requested Status
William Grant db Needs Information
Review via email: mp+436604@code.launchpad.net

Commit message

Make Artifactory publishing columns non-nullable

Description of the change

The backfill jobs have all finished everywhere now.

To post a comment you must log in.
Revision history for this message
William Grant (wgrant) wrote :

Neither SPPH.format nor BPPH.binarypackageformat are indexed, so this will likely heavily lock the tables for Some Time.

I also forget if `ALTER COLUMN ... SET NOT NULL` will use an index at all.
We have catalog hacked for this sort of thing in the past, but ideally we'd avoid it again.

review: Needs Information (db)
Revision history for this message
Colin Watson (cjwatson) wrote :

It is apparently impossible to avoid the long lock and sequential scan in PostgreSQL < 12 without catalog hacking, although as of 12 it can be done using check constraints (not indexes):

  https://www.postgresql.org/message-id/1034971590734717%40mail.yandex.ru

Unmerged commits

3e854fa... by Colin Watson

Make Artifactory publishing columns non-nullable

The backfill jobs have all finished everywhere now.

Succeeded
[SUCCEEDED] docs:0 (build)
[SUCCEEDED] lint:0 (build)
[SUCCEEDED] mypy:0 (build)
13 of 3 results

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/database/schema/patch-2211-08-0.sql b/database/schema/patch-2211-08-0.sql
2new file mode 100644
3index 0000000..6fc3e2f
4--- /dev/null
5+++ b/database/schema/patch-2211-08-0.sql
6@@ -0,0 +1,16 @@
7+-- Copyright 2023 Canonical Ltd. This software is licensed under the
8+-- GNU Affero General Public License version 3 (see the file LICENSE).
9+
10+SET client_min_messages=ERROR;
11+
12+ALTER TABLE Archive
13+ ALTER COLUMN publishing_method SET NOT NULL,
14+ ALTER COLUMN repository_format SET NOT NULL;
15+
16+ALTER TABLE SourcePackagePublishingHistory
17+ ALTER COLUMN format SET NOT NULL;
18+
19+ALTER TABLE BinaryPackagePublishingHistory
20+ ALTER COLUMN binarypackageformat SET NOT NULL;
21+
22+INSERT INTO LaunchpadDatabaseRevision VALUES (2211, 08, 0);

Subscribers

People subscribed via source and target branches

to status/vote changes: