{"action":"created","comment":{"url":"https://api.github.com/repos/mozilla/balrog/pulls/comments/69900390","id":69900390,"diff_hunk":"@@ -787,32 +787,42 @@ def getRulesMatchingQuery(self, updateQuery, fallbackChannel, transaction=None):\n         \"\"\"Returns all of the rules that match the given update query.\n            For cases where a particular updateQuery channel has no\n            fallback, fallbackChannel should match the channel from the query.\"\"\"\n-        where = [\n-            ((self.product == updateQuery['product']) | (self.product == null())) &\n-            ((self.buildTarget == updateQuery['buildTarget']) | (self.buildTarget == null())) &\n-            ((self.headerArchitecture == updateQuery['headerArchitecture']) | (self.headerArchitecture == null()))\n-        ]\n-        # Query version 2 doesn't have distribution information, and to keep\n-        # us maximally flexible, we won't match any rules that have\n-        # distribution update set.\n-        if updateQuery['queryVersion'] == 2:\n-            where.extend([(self.distribution == null()) & (self.distVersion == null())])\n-        # Only query versions 3 and 4 have distribution information, so we\n-        # need to consider it.\n-        if updateQuery['queryVersion'] in (3, 4):\n-            where.extend([\n-                ((self.distribution == updateQuery['distribution']) | (self.distribution == null())) &\n-                ((self.distVersion == updateQuery['distVersion']) | (self.distVersion == null()))\n-            ])\n-        if not updateQuery['force']:\n-            where.append(self.backgroundRate > 0)\n-        rules = self.select(where=where, transaction=transaction)\n-        self.log.debug(\"where: %s\" % where)\n+\n+        def getRawMatches():\n+            where = [\n+                ((self.product == updateQuery['product']) | (self.product == null())) &\n+                ((self.buildTarget == updateQuery['buildTarget']) | (self.buildTarget == null())) &\n+                ((self.headerArchitecture == updateQuery['headerArchitecture']) | (self.headerArchitecture == null()))\n+            ]\n+            # Query version 2 doesn't have distribution information, and to keep\n+            # us maximally flexible, we won't match any rules that have\n+            # distribution update set.\n+            if updateQuery['queryVersion'] == 2:\n+                where.extend([(self.distribution == null()) & (self.distVersion == null())])\n+            # Only query versions 3 and 4 have distribution information, so we\n+            # need to consider it.\n+            if updateQuery['queryVersion'] in (3, 4):\n+                where.extend([\n+                    ((self.distribution == updateQuery['distribution']) | (self.distribution == null())) &\n+                    ((self.distVersion == updateQuery['distVersion']) | (self.distVersion == null()))\n+                ])\n+            if not updateQuery['force']:\n+                where.append(self.backgroundRate > 0)\n+\n+            self.log.debug(\"where: %s\" % where)\n+            return self.select(where=where, transaction=transaction)\n+\n+        cache_key = \"%s-%s-%s-%s-%s-%s\" % \\\n+            (updateQuery[\"product\"], updateQuery[\"buildTarget\"], updateQuery[\"headerArchitecture\"],\n+             updateQuery.get(\"distribution\"), updateQuery.get(\"distVersion\"), updateQuery[\"force\"])\n+        rules = cache.get(\"rules\", cache_key, getRawMatches)","path":"auslib/db.py","position":53,"original_position":53,"commit_id":"a1acc2cb8e4f1b499e49f9f35ab86e22a18955c8","original_commit_id":"a1acc2cb8e4f1b499e49f9f35ab86e22a18955c8","user":{"login":"mozbhearsum","id":49649,"avatar_url":"https://avatars.githubusercontent.com/u/49649?v=3","gravatar_id":"","url":"https://api.github.com/users/mozbhearsum","html_url":"https://github.com/mozbhearsum","followers_url":"https://api.github.com/users/mozbhearsum/followers","following_url":"https://api.github.com/users/mozbhearsum/following{/other_user}","gists_url":"https://api.github.com/users/mozbhearsum/gists{/gist_id}","starred_url":"https://api.github.com/users/mozbhearsum/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozbhearsum/subscriptions","organizations_url":"https://api.github.com/users/mozbhearsum/orgs","repos_url":"https://api.github.com/users/mozbhearsum/repos","events_url":"https://api.github.com/users/mozbhearsum/events{/privacy}","received_events_url":"https://api.github.com/users/mozbhearsum/received_events","type":"User","site_admin":false},"body":"Good point, I'll change this up.","created_at":"2016-07-07T12:54:09Z","updated_at":"2016-07-07T12:54:09Z","html_url":"https://github.com/mozilla/balrog/pull/97#discussion_r69900390","pull_request_url":"https://api.github.com/repos/mozilla/balrog/pulls/97","_links":{"self":{"href":"https://api.github.com/repos/mozilla/balrog/pulls/comments/69900390"},"html":{"href":"https://github.com/mozilla/balrog/pull/97#discussion_r69900390"},"pull_request":{"href":"https://api.github.com/repos/mozilla/balrog/pulls/97"}}},"pull_request":{"url":"https://api.github.com/repos/mozilla/balrog/pulls/97","id":76492203,"html_url":"https://github.com/mozilla/balrog/pull/97","diff_url":"https://github.com/mozilla/balrog/pull/97.diff","patch_url":"https://github.com/mozilla/balrog/pull/97.patch","issue_url":"https://api.github.com/repos/mozilla/balrog/issues/97","number":97,"state":"open","locked":false,"title":"First pass at rule caching.","user":{"login":"mozbhearsum","id":49649,"avatar_url":"https://avatars.githubusercontent.com/u/49649?v=3","gravatar_id":"","url":"https://api.github.com/users/mozbhearsum","html_url":"https://github.com/mozbhearsum","followers_url":"https://api.github.com/users/mozbhearsum/followers","following_url":"https://api.github.com/users/mozbhearsum/following{/other_user}","gists_url":"https://api.github.com/users/mozbhearsum/gists{/gist_id}","starred_url":"https://api.github.com/users/mozbhearsum/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozbhearsum/subscriptions","organizations_url":"https://api.github.com/users/mozbhearsum/orgs","repos_url":"https://api.github.com/users/mozbhearsum/repos","events_url":"https://api.github.com/users/mozbhearsum/events{/privacy}","received_events_url":"https://api.github.com/users/mozbhearsum/received_events","type":"User","site_admin":false},"body":"This is a first crack at doing full-table caching of rules (the second option listed at https://bugzilla.mozilla.org/show_bug.cgi?id=1111032#c0). There's no invalidation necessary here because this code only runs on the public nodes, and they cannot modify rules.\r\n\r\nThis patch introduces an extra delay of up to 30 seconds between making a rule change, and having it take effect. This is on top of the existing 60 second cache at zeus (webops) or nginx (cloudops).\r\n\r\nI haven't done a lot of self review or testing yet, I wanted to get this up for quick feedback anyways though.","created_at":"2016-07-06T20:01:56Z","updated_at":"2016-07-07T12:54:09Z","closed_at":null,"merged_at":null,"merge_commit_sha":"cf45045504bfe4f62d64514a269d265d55876b69","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/mozilla/balrog/pulls/97/commits","review_comments_url":"https://api.github.com/repos/mozilla/balrog/pulls/97/comments","review_comment_url":"https://api.github.com/repos/mozilla/balrog/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mozilla/balrog/issues/97/comments","statuses_url":"https://api.github.com/repos/mozilla/balrog/statuses/a1acc2cb8e4f1b499e49f9f35ab86e22a18955c8","head":{"label":"mozbhearsum:rule-cache","ref":"rule-cache","sha":"a1acc2cb8e4f1b499e49f9f35ab86e22a18955c8","user":{"login":"mozbhearsum","id":49649,"avatar_url":"https://avatars.githubusercontent.com/u/49649?v=3","gravatar_id":"","url":"https://api.github.com/users/mozbhearsum","html_url":"https://github.com/mozbhearsum","followers_url":"https://api.github.com/users/mozbhearsum/followers","following_url":"https://api.github.com/users/mozbhearsum/following{/other_user}","gists_url":"https://api.github.com/users/mozbhearsum/gists{/gist_id}","starred_url":"https://api.github.com/users/mozbhearsum/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozbhearsum/subscriptions","organizations_url":"https://api.github.com/users/mozbhearsum/orgs","repos_url":"https://api.github.com/users/mozbhearsum/repos","events_url":"https://api.github.com/users/mozbhearsum/events{/privacy}","received_events_url":"https://api.github.com/users/mozbhearsum/received_events","type":"User","site_admin":false},"repo":{"id":2570483,"name":"balrog","full_name":"mozbhearsum/balrog","owner":{"login":"mozbhearsum","id":49649,"avatar_url":"https://avatars.githubusercontent.com/u/49649?v=3","gravatar_id":"","url":"https://api.github.com/users/mozbhearsum","html_url":"https://github.com/mozbhearsum","followers_url":"https://api.github.com/users/mozbhearsum/followers","following_url":"https://api.github.com/users/mozbhearsum/following{/other_user}","gists_url":"https://api.github.com/users/mozbhearsum/gists{/gist_id}","starred_url":"https://api.github.com/users/mozbhearsum/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozbhearsum/subscriptions","organizations_url":"https://api.github.com/users/mozbhearsum/orgs","repos_url":"https://api.github.com/users/mozbhearsum/repos","events_url":"https://api.github.com/users/mozbhearsum/events{/privacy}","received_events_url":"https://api.github.com/users/mozbhearsum/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/mozbhearsum/balrog","description":"Next generation update service for Mozilla products","fork":true,"url":"https://api.github.com/repos/mozbhearsum/balrog","forks_url":"https://api.github.com/repos/mozbhearsum/balrog/forks","keys_url":"https://api.github.com/repos/mozbhearsum/balrog/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mozbhearsum/balrog/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mozbhearsum/balrog/teams","hooks_url":"https://api.github.com/repos/mozbhearsum/balrog/hooks","issue_events_url":"https://api.github.com/repos/mozbhearsum/balrog/issues/events{/number}","events_url":"https://api.github.com/repos/mozbhearsum/balrog/events","assignees_url":"https://api.github.com/repos/mozbhearsum/balrog/assignees{/user}","branches_url":"https://api.github.com/repos/mozbhearsum/balrog/branches{/branch}","tags_url":"https://api.github.com/repos/mozbhearsum/balrog/tags","blobs_url":"https://api.github.com/repos/mozbhearsum/balrog/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mozbhearsum/balrog/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mozbhearsum/balrog/git/refs{/sha}","trees_url":"https://api.github.com/repos/mozbhearsum/balrog/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mozbhearsum/balrog/statuses/{sha}","languages_url":"https://api.github.com/repos/mozbhearsum/balrog/languages","stargazers_url":"https://api.github.com/repos/mozbhearsum/balrog/stargazers","contributors_url":"https://api.github.com/repos/mozbhearsum/balrog/contributors","subscribers_url":"https://api.github.com/repos/mozbhearsum/balrog/subscribers","subscription_url":"https://api.github.com/repos/mozbhearsum/balrog/subscription","commits_url":"https://api.github.com/repos/mozbhearsum/balrog/commits{/sha}","git_commits_url":"https://api.github.com/repos/mozbhearsum/balrog/git/commits{/sha}","comments_url":"https://api.github.com/repos/mozbhearsum/balrog/comments{/number}","issue_comment_url":"https://api.github.com/repos/mozbhearsum/balrog/issues/comments{/number}","contents_url":"https://api.github.com/repos/mozbhearsum/balrog/contents/{+path}","compare_url":"https://api.github.com/repos/mozbhearsum/balrog/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mozbhearsum/balrog/merges","archive_url":"https://api.github.com/repos/mozbhearsum/balrog/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mozbhearsum/balrog/downloads","issues_url":"https://api.github.com/repos/mozbhearsum/balrog/issues{/number}","pulls_url":"https://api.github.com/repos/mozbhearsum/balrog/pulls{/number}","milestones_url":"https://api.github.com/repos/mozbhearsum/balrog/milestones{/number}","notifications_url":"https://api.github.com/repos/mozbhearsum/balrog/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mozbhearsum/balrog/labels{/name}","releases_url":"https://api.github.com/repos/mozbhearsum/balrog/releases{/id}","deployments_url":"https://api.github.com/repos/mozbhearsum/balrog/deployments","created_at":"2011-10-13T15:58:54Z","updated_at":"2015-04-10T17:04:36Z","pushed_at":"2016-07-06T19:55:13Z","git_url":"git://github.com/mozbhearsum/balrog.git","ssh_url":"git@github.com:mozbhearsum/balrog.git","clone_url":"https://github.com/mozbhearsum/balrog.git","svn_url":"https://github.com/mozbhearsum/balrog","homepage":"","size":31167,"stargazers_count":2,"watchers_count":2,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":0,"forks":1,"open_issues":0,"watchers":2,"default_branch":"master"}},"base":{"label":"mozilla:master","ref":"master","sha":"8b6c33d301d25e2df4585d94d78e8cb51f2fcb78","user":{"login":"mozilla","id":131524,"avatar_url":"https://avatars.githubusercontent.com/u/131524?v=3","gravatar_id":"","url":"https://api.github.com/users/mozilla","html_url":"https://github.com/mozilla","followers_url":"https://api.github.com/users/mozilla/followers","following_url":"https://api.github.com/users/mozilla/following{/other_user}","gists_url":"https://api.github.com/users/mozilla/gists{/gist_id}","starred_url":"https://api.github.com/users/mozilla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozilla/subscriptions","organizations_url":"https://api.github.com/users/mozilla/orgs","repos_url":"https://api.github.com/users/mozilla/repos","events_url":"https://api.github.com/users/mozilla/events{/privacy}","received_events_url":"https://api.github.com/users/mozilla/received_events","type":"Organization","site_admin":false},"repo":{"id":2570444,"name":"balrog","full_name":"mozilla/balrog","owner":{"login":"mozilla","id":131524,"avatar_url":"https://avatars.githubusercontent.com/u/131524?v=3","gravatar_id":"","url":"https://api.github.com/users/mozilla","html_url":"https://github.com/mozilla","followers_url":"https://api.github.com/users/mozilla/followers","following_url":"https://api.github.com/users/mozilla/following{/other_user}","gists_url":"https://api.github.com/users/mozilla/gists{/gist_id}","starred_url":"https://api.github.com/users/mozilla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozilla/subscriptions","organizations_url":"https://api.github.com/users/mozilla/orgs","repos_url":"https://api.github.com/users/mozilla/repos","events_url":"https://api.github.com/users/mozilla/events{/privacy}","received_events_url":"https://api.github.com/users/mozilla/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mozilla/balrog","description":"Next generation update service for Mozilla products","fork":false,"url":"https://api.github.com/repos/mozilla/balrog","forks_url":"https://api.github.com/repos/mozilla/balrog/forks","keys_url":"https://api.github.com/repos/mozilla/balrog/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mozilla/balrog/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mozilla/balrog/teams","hooks_url":"https://api.github.com/repos/mozilla/balrog/hooks","issue_events_url":"https://api.github.com/repos/mozilla/balrog/issues/events{/number}","events_url":"https://api.github.com/repos/mozilla/balrog/events","assignees_url":"https://api.github.com/repos/mozilla/balrog/assignees{/user}","branches_url":"https://api.github.com/repos/mozilla/balrog/branches{/branch}","tags_url":"https://api.github.com/repos/mozilla/balrog/tags","blobs_url":"https://api.github.com/repos/mozilla/balrog/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mozilla/balrog/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mozilla/balrog/git/refs{/sha}","trees_url":"https://api.github.com/repos/mozilla/balrog/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mozilla/balrog/statuses/{sha}","languages_url":"https://api.github.com/repos/mozilla/balrog/languages","stargazers_url":"https://api.github.com/repos/mozilla/balrog/stargazers","contributors_url":"https://api.github.com/repos/mozilla/balrog/contributors","subscribers_url":"https://api.github.com/repos/mozilla/balrog/subscribers","subscription_url":"https://api.github.com/repos/mozilla/balrog/subscription","commits_url":"https://api.github.com/repos/mozilla/balrog/commits{/sha}","git_commits_url":"https://api.github.com/repos/mozilla/balrog/git/commits{/sha}","comments_url":"https://api.github.com/repos/mozilla/balrog/comments{/number}","issue_comment_url":"https://api.github.com/repos/mozilla/balrog/issues/comments{/number}","contents_url":"https://api.github.com/repos/mozilla/balrog/contents/{+path}","compare_url":"https://api.github.com/repos/mozilla/balrog/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mozilla/balrog/merges","archive_url":"https://api.github.com/repos/mozilla/balrog/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mozilla/balrog/downloads","issues_url":"https://api.github.com/repos/mozilla/balrog/issues{/number}","pulls_url":"https://api.github.com/repos/mozilla/balrog/pulls{/number}","milestones_url":"https://api.github.com/repos/mozilla/balrog/milestones{/number}","notifications_url":"https://api.github.com/repos/mozilla/balrog/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mozilla/balrog/labels{/name}","releases_url":"https://api.github.com/repos/mozilla/balrog/releases{/id}","deployments_url":"https://api.github.com/repos/mozilla/balrog/deployments","created_at":"2011-10-13T15:51:47Z","updated_at":"2016-05-18T03:09:48Z","pushed_at":"2016-07-06T20:01:56Z","git_url":"git://github.com/mozilla/balrog.git","ssh_url":"git@github.com:mozilla/balrog.git","clone_url":"https://github.com/mozilla/balrog.git","svn_url":"https://github.com/mozilla/balrog","homepage":"","size":28783,"stargazers_count":16,"watchers_count":16,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":29,"mirror_url":null,"open_issues_count":7,"forks":29,"open_issues":7,"watchers":16,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mozilla/balrog/pulls/97"},"html":{"href":"https://github.com/mozilla/balrog/pull/97"},"issue":{"href":"https://api.github.com/repos/mozilla/balrog/issues/97"},"comments":{"href":"https://api.github.com/repos/mozilla/balrog/issues/97/comments"},"review_comments":{"href":"https://api.github.com/repos/mozilla/balrog/pulls/97/comments"},"review_comment":{"href":"https://api.github.com/repos/mozilla/balrog/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mozilla/balrog/pulls/97/commits"},"statuses":{"href":"https://api.github.com/repos/mozilla/balrog/statuses/a1acc2cb8e4f1b499e49f9f35ab86e22a18955c8"}}}}
{"actor":{"display_login":"mozbhearsum"}}