/srv/irclogs.ubuntu.com/2020/02/27/#launchpad-dev.txt

wgrantNOTICE:  identifier "binarypackagereleasedownloadcount__archive__bpr__day__count__idx" will be truncated to "binarypackagereleasedownloadcount__archive__bpr__day__count__id"08:06
wgrantso. close.08:06
wgrantcjwatson: Index addition to optimise BPRDC queries, if you have a moment: https://code.launchpad.net/~wgrant/launchpad/+git/launchpad/+merge/37994209:12
tomwardillwgrant: if you're about, I have a column in the OCI stuff that needs to be NOT NULL, is it safe to add a migration to do that (given we should have 0 rows atm)09:20
wgrant(prevents HOT updates, but almost certainly worth it given that updates are async)09:20
wgranttomwardill: Yep09:20
tomwardillrighto09:21
* tomwardill does the thing09:21
cjwatsonwgrant: Is it worth including country as well?  Archive.getPackageDownloadCount uses that10:36
wgrantcjwatson: It'd make the index a bit wider, and nobody really cares about the country breakdown, but it's true it wouldn't cost much more at all.10:37
wgrantI suppose we might as well.10:37
wgrantIt's how I'd model it in Cassandra were I not doing it in 2009.10:37
wgrantcommit 1c040ea5ee863a784fb85b1a6455668f94e0d0be10:38
wgrantAuthor: William Grant <me@williamgrant.id.au>10:38
wgrantDate:   Sat Feb 20 15:36:29 2010 +110010:38
wgrant    Add and test Archive.updatePackageDownloadCount.10:38
wgrantJust made it ten years10:39
wgrantnice10:39
wgrantTen years and close to a billion rows before it needed significant revision.10:39
SpecialK|CanonNice10:41
wgrantWhen we upgrade to PostgreSQL >=11 we can replace this index and binarypackagereleasedownloadcount__archive__binary_package_rele (the UNIQUE constraint) with a new UNIQUE constraint with INCLUDE (count), but for now we can afford the extra 30GB.10:42
wgrantRight, that additional column is worth it just because it makes the commit message wrapping less ugly.10:43
wgrantcjwatson: Updated.10:43
wgrantcjwatson: btw I got some bug update timeouts earlier, but they seemed shorter lived -- and now much easier to debug, as there's a lot less that can be going wrong in the new triggers.10:45
wgrantI wonder if we can capture interesting bits of pg_locks regularly10:45
cjwatsonwgrant: Should it be "count, country" rather than "country, count" so that the query in getDailyDownloadTotals can use the partial index more effectively?10:47
cjwatson(Feel free to tell me that this doesn't matter in practice)10:47
cjwatsonwgrant: Anything interesting in the bug update oopses?10:48
wgrantcjwatson: It's important that it be country, count, or the queries that filter on country can't use it effectively. You can only efficiently filter on a prefix -- if you filter on something other than a prefix, you end up having to scan through the intermediate columns.10:48
wgrantBut if you're not filtering on country then you are scanning through all the tuples anyway, so the fact you can't filter by country isn't problematic.10:49
cjwatsonwgrant: Right, but doesn't getDailyDownloadTotals filter on only archive, bpr, day, count?10:49
wgrantIt doesn't filter on count. It selects it.10:49
cjwatsonOh no, I see, it's getting count from the index but ... that10:49
wgranthttps://oops.canonical.com/oops/?oopsid=OOPS-ae3af2c30556a12f4fe8f8acf345a41910:49
cjwatsonGot it10:49
wgranthttps://oops.canonical.com/oops/?oopsid=OOPS-f0f9a7577246c3195e93f200cbb32ca110:50
cjwatsonwgrant: r=me10:50
wgrantcjwatson: And I assume db=you?10:50
wgrantAh yes10:50
cjwatsonIndeed10:50
wgrantWill get it applied hot.10:51
wgrantAnd hopefully we weren't relying too much on HOT10:51
wgrantBut given the nature of PPAALP, probably not10:51
cjwatsonSo those timeouts rule out the theory (which may have been only spitballing to start with) that it was a lock that prevented the creation of temporary tables10:52
wgrantIt was only spitballing, though I'm pretty confident we did narrow it down to the bugsummary triggers at one point.10:52
wgrantBut there are very limited locks that can have caused that timeout. Mostly a row lock on bugtaskflat.10:52
cjwatsonPresumably the bugsummary triggers, though it's annoying that the pseudo-traceback doesn't say that10:56
cjwatsonI wondered whether it might be a deadlock with the BugSummaryJournalRollup garbo job somehow, but logs show that that job wasn't running at the time of https://oops.canonical.com/oops/?oopsid=OOPS-ae3af2c30556a12f4fe8f8acf345a41910:58
wgrantBut unless we're SERIALIZABLE they shouldn't be able to conflict, since the trigger only inserts journal rows.11:00
wgrantI think reporting on long locks on bugtaskflat might be interesting.11:00
cjwatsonAgreed.  How do we organise that?11:02
cjwatsonPerhaps stub can help11:03
tomwardillstand back, twom made a DB patch! https://code.launchpad.net/~twom/launchpad/+git/launchpad/+merge/37996011:12
wgranttomwardill: Wasn't the intent that git_repository_url was to be an alternative?11:13
wgrantLike snap.git_repository_url11:13
cjwatsonI recall deciding YAGNI on that for the moment11:13
tomwardillwgrant: I think eventually, yes. But for now, git_repository_url doesn't exist.11:14
tomwardillso atm it's possible to create OCIRecipes that make no sense as there's no source11:14
wgrantFair enough, db=me11:15
tomwardillso I should be able to Top Approve that, then provide the equivalent code patch?11:18
wgrantI don't think there's a particular sequencing constraint between the DB and code patches here, but yes.11:19
cjwatsonRight, code can land concurrently with that as long as the code does the corresponding checks (which IIRC it does)11:20
ilascSigning Service question: looking at the code / data model I think we have a 1:1 mapping for: Client (one) <-> (one) ClientPublicKey11:29
ilasccan I please get a confirmation on that being the case in the real world too, sqlAlchemy requires explicit mapping definition11:29
cjwatsonilasc: No.  A client may have multiple public keys.11:30
cjwatsonIt's explicitly not one-to-one, because that would make it impossible to do rotation.11:30
cjwatsonilasc: Note the existence of Client.public_keys11:30
ilasccjwatson: excellent, indeed saw that now that u mentioned it, thank you!11:31
tomwardillah, cool. All the code appears to assume that git_repository is required11:33
tomwardillalthough I found a typo in an error message11:33
cjwatsontomwardill: Will take a while anyway - Thiago has a patch ahead of you in the DB queue11:38
tomwardillno problems, I think there's just the DB patch for that, so it can wait a bit :)11:39
cjwatsonLet me get a ticket in for that one at least11:39
wgrantcjwatson: I think we can consider relaxing the one patch per deployment constraint for obviously fine cases.11:40
wgrantWe've done it once or twice in the past.11:40
wgrantAnd it's been a long time since we've actually run into deployment trouble.11:40
cjwatsonThis is true11:41
cjwatsonThe documented rule is "not without manual approval" anyway11:41
cjwatsonSo we can just manually approve obviously fine cases :)11:41
tomwardilltiny typo fix while I don't forget: https://code.launchpad.net/~twom/launchpad/+git/launchpad/+merge/37996111:41
cjwatsonI updated LPS for Thiago's patch, but I'll just wait until Tom's passes buildbot and gets onto staging, and then update the commit ID before filing the ticket11:42
wgrantLike I wouldn't deploy the bugsummary triggers and the BPRDC index at the same time, because they both have unpredictable performance implications.11:42
cjwatsontomwardill: r=me11:42
cjwatsonYeah11:43
* tomwardill tries to remember where he left the OCIProject UI patch11:44
=== wgrant is now known as wgrant_
=== wgrant_ is now known as wgrant
cjwatsonwgrant: Could you comment on the indexing problem in https://code.launchpad.net/~pappacena/launchpad/+git/launchpad/+merge/379218 ?13:09
cjwatsonI'm not sure we've split up {,Archive}SigningKey in the right way.13:10
cjwatsonMaybe key_type needs to be denormalised onto ArchiveSigningKey?13:10
wgrantcjwatson: Hm, are type and purpose somewhat orthogonal?13:12
wgrantThe restriction is on the purpose, not necessarily the type.13:12
wgrantBut yes, if we want to say type == purpose then the way to express the constraint would be to denorm SigningKey.type onto ArchiveSigningKey and add a composite FK13:12
cjwatsonwgrant: Not really usefully orthogonal, because lp-signing needs to know more than just the bare key type in order to implement the right signing logic13:13
wgrantTrue.13:13
wgrantI'm thinking of cases like existing OpenPGP archive signing keys, which are used to sign not just indexes but also directly signable customs.13:15
cjwatsonComposite FK as in ADD CONSTRAINT archivesigningkey__key_type__signing_key__fk FOREIGN KEY (key_type, signing_key) REFERENCES signingkey (key_type, signing_key) right?13:16
wgrantRight.13:16
cjwatsonI'm trying to think if even the OpenPGP case would benefit from type != purpose.13:18
cjwatsonI can't quite see how it would.13:18
cjwatsonIt would only benefit if we had a use case for multiple different OpenPGP keys per (archive, [series]) that were used for different things.13:19
wgrantRight13:19
pappacenaCan't we create a trigger to check if we are not creating more than one ArchiveSigningKey with the same key type, and prevent the duplication of key_type in ArchivesSigningKey table?13:19
cjwatsonpappacena: composite FKs are simpler than triggers13:19
wgrantWe have that for UEFI today, though it happens that the alternate key is only held by Microsoft.13:19
cjwatsonAnd denormalisation is permitted13:20
wgrantMaking the trigger non-racy would also be somewhere between difficult and impossible.13:20
wgrantWe're likely to need more granularity on things like FIT keys later13:21
wgrantBut I guess we can do that later.13:21
cjwatsonI was thinking that that granularity would be more likely to be expressed by extra columns on ArchiveSigningKey (e.g. sourcepackagename, not that I'm enthusiastic about that)13:22
cjwatsonBut perhaps I don't understand what the likely changes are13:23
cjwatsonAt any rate, the composite FK approach doesn't preclude type != purpose later if we need to; we'd add an extra purpose column, relax the index, and maybe add a constraint for the permitted combinations of type and purpose13:25
cjwatsons/index/unique constraint/13:25
wgrantYep, fair enough.13:26
wgrantsourcepackagename for FIT, arch for UEFI, that sort of thing13:26
cjwatsonYeah13:27
wgrantThe signing service could conceivably have a key type of X.509 with purpose restriction UEFI, then LP ties that to series and arches and packages13:28
wgrantAlso a key type of OpenPGP with purpose restriction APT_INDEX and DIST_UPGRADER13:28
pappacenaJust to make sure I understood it correctly, this granularity doesn't exist today, right?13:28
wgrantSince currently those are the same key, but there's no actual reason for that.13:28
wgrantRight, not needed today. It's only by upload type and series so far.13:29
cjwatsonFor X.509, I prefer to have the signing service have different key types if the signing process requires using a different binary (sbsign vs. kmodsign), even if they're technically the same type of key material.  But otherwise fair enough.13:30
cjwatsonTo me that's slightly more than a restriction of purpose (which is about which keys may validly be selected for use).13:30
cjwatsonCombination of key type and mechanism, perhaps, but collapsed into key_type13:31
wgrantRight, but I'm wondering if in some cases they might be the same key material.13:46
wgrantWhich we could just duplicate, of course.13:46
pappacenaI think we could just have several ArchiveSigningKey with different "filters" pointing to the same SigningKey object (on LP's database and lp-signing service)13:50
pappacenaAnd having different key_types (meaning "purpose", and not really the key file format), there shouldn't be a problem with the unique constraint.13:53
cjwatsonYep, we already have that situation for keys that have currently been manually copied between archives13:56
* SpecialK|Canon watches Chromium spin14:00
cjwatsonIt's true that we might end up with SigningKeys that have the same material in some cases.  Duplication probably isn't the worst thing there14:02
wgrantOK14:03
cjwatsontomwardill: http://lpbuildbot.canonical.com/builders/lp-db-devel-xenial/builds/874/steps/shell_9/logs/summary   oh dear, that DB patch is going to have trouble until we get some code changes landed on production14:17
tomwardillthat's... weird14:18
tomwardillI ran those tests14:18
cjwatsonDid you definitely apply the DB patch to the launchpad_ftest_template DB?14:18
cjwatsontomwardill: I'm going to go ahead and request that Thiago's DB patch be deployed, since yours seems likely to be blocked for a bit14:19
tomwardillhmm, maybe no. I ran ./database/schema/update.py14:19
tomwardillcjwatson: sure, go ahead14:19
tomwardillI'll replicate and fix14:19
cjwatsondatabase/schema/upgrade.py defaults to, err, I'm not sure which but probably launchpad_dev14:20
cjwatsonIt takes a -d option14:20
tomwardillyeah. The one time I don't just run `make schema` and try to be all fancy, it bites me :)14:20
cjwatsonWell, you don't need to do that necessarily14:20
cjwatsonYou can run upgrade.py on all five (launchpad_empty, launchpad_dev_template, launchpad_dev, launchpad_ftest_template, launchpad_ftest_playground) to make sure14:21
pappacenaI think it defaults to launchpad_dev... I ran it few days ago without the '-d'...14:21
cjwatsonAnd usually best to do likewise with security.py14:21
* tomwardill improves notes14:21
cjwatsonHaving a "make -C database/schema migrate" or similar to do them all might not be the worst thing in the world14:21
cjwatsonThough with a comment that it's only for development14:23
tomwardillaaah, there we go, that's all the errors I was kind of expecting14:28
tomwardillTotal: 100 tests, 0 failures, 52 errors, 0 skipped in 52.836 seconds.14:28
* tomwardill coughs14:28
tomwardillhmm, why would `self.git_repository = value.repository` trigger the NOT NULL constraint? I'm setting the value, not trying to read it14:36
tomwardill cjwatson: I can't work out why this line: https://git.launchpad.net/launchpad/tree/lib/lp/oci/model/ocirecipe.py#n156 when called via the makeOCIRecipe method in factory.py is causing a storm flush. Any hints?15:10
cjwatsontomwardill: Have you tried it with LP_DEBUG_SQL=1 ?15:11
tomwardillcjwatson: yeah, it seems to do a select, then an insert: https://pastebin.canonical.com/p/dfSbgR9NmN/15:14
tomwardillthe insert is missing the git_repository value15:14
tomwardillbut I've no idea why15:14
tomwardill(well, it's doing the insert on the line that the git_repository value is being set, so it's more 'why is it doing this insert' rather than 'why is git_repository missing')15:15
cjwatsonThis sort of thing usually happens when it needs to flush something in order to get an ID15:15
cjwatsonIIRC in Snap I had to order some things very carefully to avoid this15:16
cjwatsonWhich of the failing tests is this?15:16
tomwardilllp.oci.tests.test_ocirecipebuild.TestOCIRecipeBuild.test_queueBuild15:17
tomwardillalthough I think it's the same symptom in most of them15:17
cjwatsonOK, give me a few minutes to upgrade15:18
cjwatsonAh, of course.  Snap doesn't run into this because it's intentionally possible to have a Snap without any source at all, in order to avoid blocking repository deletion on deleting snaps built on it.  Instead, we just "detach" the snap when the source is deleted, leaving it with all of branch, git_repository, and git_repository_url being NULL.15:30
cjwatsonAnd there's a check in SnapBuildBehaviour.extraBuildArgs to refuse to dispatch a build of a snap that's in this state.15:31
tomwardillaha15:31
tomwardillthat explains the checks in there (like the git_ref setter allowing it to be None)15:31
cjwatsonSo while we could fix this by more careful ordering in some way (because you need to get hold of stuff from the GitRef row before you populate anything in the new OCIRecipe row), I think it would be better to just revert this DB patch for the same reasons.15:32
cjwatsonAnd implement the same detaching logic for OCIRecipe.15:32
* cjwatson slowly loads stuff back into their brain15:32
tomwardillsure, that makes sense15:32
cjwatsonSorry for misleading you about this15:33
cjwatsonYou'll need to add a bit of stuff to the machinery around GitRepository.destroySelf as well15:34
tomwardillno worries :)15:34
cjwatsonLook for detachFromGitRepository15:34
cjwatsonWe can just revert the DB patch directly rather than doing anything more clever; because it hasn't passed buildbot, it isn't on staging or anything like that15:35
cjwatsonAnyone who's applied it locally will have to manually unapply it (DROP NOT NULL and delete the LaunchpadDatabaseRevision row), but that's probably just the two of us15:36
tomwardillincoming MP :)15:36
tomwardillhttps://code.launchpad.net/~twom/launchpad/+git/launchpad/+merge/37997815:36
cjwatsondb=me15:37
tomwardilllanding15:38
cjwatsonfor db in launchpad_empty launchpad_dev_template launchpad_dev launchpad_ftest_template launchpad_ftest_playground; do psql -c 'ALTER TABLE OCIRecipe ALTER COLUMN git_repository DROP NOT NULL;' -c 'DELETE FROM LaunchpadDatabaseRevision WHERE major = 2210 AND minor = 8 AND patch = 4;' "$db"; done15:39
cjwatson^- manual revert15:39
tomwardillace :)15:40
* tomwardill blindly copy pastes random things from irc...15:40
cjwatsonRobert'); DROP TABLE Students;--15:41
tomwardillthere's at least one company named similar in companies house records15:43
cjwatsonAnyone up for reviewing https://code.launchpad.net/~cjwatson/lp-source-dependencies/+git/lp-source-dependencies/+merge/379682 and https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/379683 to make it possible to build a wheel for unittest2?16:34
tomwardillhow much work would it be to drop unittest2 entirely? Or is a dep for something more fundamental?16:37
cjwatsontesttools mainly16:43
tomwardillah, that would do it, yes16:43
cjwatsonIn fact testtools exclusively16:43
cjwatsonhttps://github.com/testing-cabal/testtools/pull/27716:43
tomwardill+1 to both16:45
cjwatsonThanks16:45

Generated by irclog2html.py 2.7 by Marius Gedminas - find it at mg.pov.lt!