Merge lp:~cjwatson/launchpad/process-job-source-groups-locking into lp:launchpad

Proposed by Colin Watson
Status: Merged
Approved by: Colin Watson
Approved revision: no longer in the source branch.
Merged at revision: 15713
Proposed branch: lp:~cjwatson/launchpad/process-job-source-groups-locking
Merge into: lp:launchpad
Diff against target: 53 lines (+9/-9)
2 files modified
cronscripts/process-job-source-groups.py (+3/-1)
lib/lp/registry/tests/test_process_job_sources_cronjob.py (+6/-8)
To merge this branch: bzr merge lp:~cjwatson/launchpad/process-job-source-groups-locking
Reviewer Review Type Date Requested Status
Benji York (community) code Approve
Review via email: mp+117234@code.launchpad.net

Commit message

Stop process-job-source-groups taking its own lock.

Description of the change

== Summary ==

Bug 839659: we can't run process-job-source-groups on overlapping schedules for multiple groups (MAIN and FREQUENT) because it takes a lock whose name doesn't depend on the groups being run.

== Proposed fix ==

It really doesn't need its own lock, as it just runs process-job-source which locks anyway, so drop it.

== Tests ==

bin/test -vvct test_process_job_sources_cronjob

== Demo and Q/A ==

Run 'cronscripts/process-job-source-groups.py MAIN' and 'cronscripts/process-job-source-groups.py FREQUENT' in parallel on e.g. dogfood. Neither should block on the other, and both should process pending jobs.

== Lint ==

Just the usual false positive for scripts.

./cronscripts/process-job-source-groups.py
      10: '_pythonpath' imported but unused

To post a comment you must log in.
Revision history for this message
Benji York (benji) wrote :

Looks good.

review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'cronscripts/process-job-source-groups.py'
2--- cronscripts/process-job-source-groups.py 2012-01-01 03:14:54 +0000
3+++ cronscripts/process-job-source-groups.py 2012-07-30 10:32:06 +0000
4@@ -113,4 +113,6 @@
5
6 if __name__ == '__main__':
7 script = ProcessJobSourceGroups()
8- script.lock_and_run()
9+ # We do not need to take a lock here; all the interesting work is done
10+ # by process-job-source.py, which takes its own per-job-source locks.
11+ script.run()
12
13=== modified file 'lib/lp/registry/tests/test_process_job_sources_cronjob.py'
14--- lib/lp/registry/tests/test_process_job_sources_cronjob.py 2012-06-13 01:03:45 +0000
15+++ lib/lp/registry/tests/test_process_job_sources_cronjob.py 2012-07-30 10:32:06 +0000
16@@ -102,14 +102,15 @@
17 self.assertIn('Group: MAIN\n I', output)
18
19 def test_empty_queue(self):
20- # The script should just create a lockfile, launch a child for
21- # each job source class, and then exit if no jobs are in the queue.
22+ # The script should just launch a child for each job source class,
23+ # and then exit if no jobs are in the queue. It should not create
24+ # its own lockfile.
25 returncode, output, error = run_script(self.script, ['MAIN'])
26 expected = (
27- '.*Creating lockfile:.*launchpad-processjobsourcegroups.lock'
28 '.*Creating lockfile:.*launchpad-process-job-'
29 'source-IMembershipNotificationJobSource.lock.*')
30 self.assertTextMatchesExpressionIgnoreWhitespace(expected, error)
31+ self.assertNotIn("launchpad-processjobsourcegroups.lock", error)
32
33 def test_processed(self):
34 # The script should output the number of jobs that have been
35@@ -137,8 +138,7 @@
36 for source in self.getJobSources("MAIN"):
37 args.extend(("--exclude", source))
38 returncode, output, error = run_script(self.script, args)
39- expected = "INFO Creating lockfile: ...\n"
40- self.assertThat(error, DocTestMatches(expected))
41+ self.assertEqual("", error)
42
43 def test_exclude_non_existing_group(self):
44 # If a job source specified by --exclude does not exist the script
45@@ -148,7 +148,5 @@
46 args.extend(("--exclude", source))
47 args.extend(("--exclude", "BobbyDazzler"))
48 returncode, output, error = run_script(self.script, args)
49- expected = (
50- "INFO Creating lockfile: ...\n"
51- "INFO 'BobbyDazzler' is not in MAIN\n")
52+ expected = "INFO 'BobbyDazzler' is not in MAIN\n"
53 self.assertThat(error, DocTestMatches(expected))