Merge ~cjwatson/launchpad:mlist-sync-retry into launchpad:master

Proposed by Colin Watson
Status: Merged
Approved by: Colin Watson
Approved revision: bb97df2493723ab639812e2d20153d4ef9ac7e1e
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~cjwatson/launchpad:mlist-sync-retry
Merge into: launchpad:master
Diff against target: 37 lines (+16/-2)
1 file modified
lib/lp/services/mailman/scripts/mlist_sync.py (+16/-2)
Reviewer Review Type Date Requested Status
Ioana Lasc (community) Approve
Review via email: mp+376756@code.launchpad.net

Commit message

Retry mlist-sync's call to updateTeamAddresses

Description of the change

The new updateTeamAddresses API used by mlist-sync is a bit liable to time out when the database is cold. Testing the relevant query by hand on staging and dogfood suggests that it warms up quite quickly on subsequent calls; so, rather than doing anything more elaborate for a staging-only API, just retry the call a few times if we get an OOPS.

To post a comment you must log in.
Revision history for this message
Ioana Lasc (ilasc) wrote :

looks good.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/lib/lp/services/mailman/scripts/mlist_sync.py b/lib/lp/services/mailman/scripts/mlist_sync.py
2index 2aa245e..67f8032 100644
3--- a/lib/lp/services/mailman/scripts/mlist_sync.py
4+++ b/lib/lp/services/mailman/scripts/mlist_sync.py
5@@ -29,6 +29,7 @@ import os
6 import subprocess
7 import sys
8 import textwrap
9+import time
10
11 from six.moves.xmlrpc_client import Fault
12
13@@ -117,9 +118,22 @@ class MailingListSyncScript(LaunchpadScript):
14 from Mailman.MailList import MailList
15 from Mailman.Queue import XMLRPCRunner
16
17- # Ask Launchpad to update all the team email addresses.
18+ # Ask Launchpad to update all the team email addresses. This can be
19+ # a bit timeout-prone if the relevant tables are cold, but should
20+ # warm up reasonably quickly, so allow for a few retries.
21 proxy = XMLRPCRunner.get_mailing_list_api_proxy()
22- proxy.updateTeamAddresses(self.options.hostname)
23+ max_retries = 3
24+ for i in range(max_retries + 1):
25+ try:
26+ proxy.updateTeamAddresses(self.options.hostname)
27+ except Fault as fault:
28+ if (fault.faultCode == faults.OopsOccurred.error_code and
29+ i < max_retries):
30+ self.logger.warning(
31+ "updateTeamAddresses OOPSed. Retrying ...")
32+ time.sleep(2 ** i)
33+ else:
34+ raise
35
36 # Clean things up per mailing list.
37 for list_name in Utils.list_names():

Subscribers

People subscribed via source and target branches

to status/vote changes: