From 62ca960a5f6b956299dbb0a44d049d063962d3c5 Mon Sep 17 00:00:00 2001 From: Aaron Gable Date: Fri, 19 May 2017 17:24:52 -0700 Subject: [PATCH] gerrit_util: retry on 404s for replication lag We usually only retry on server errors. But most 404s that clients will recieve are due to replication lag, not due to querying an issue that truly doesn't exist. This CL lets gerrit_util (which is used primarily by git-cl) to retry on 404s to help fight errors due to replication lag. R=tandrii@chromium.org Bug: 717197 Change-Id: I26dbbf6c4895a13f7d57e4be3c23450111c949bc Reviewed-on: https://chromium-review.googlesource.com/510000 Reviewed-by: Andrii Shyshkalov Commit-Queue: Aaron Gable --- gerrit_util.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/gerrit_util.py b/gerrit_util.py index d1ef98957..b08f82a8a 100755 --- a/gerrit_util.py +++ b/gerrit_util.py @@ -347,7 +347,9 @@ def ReadHttpResponse(conn, accept_statuses=frozenset([200])): raise GerritAuthenticationError(response.status, reason) # If response.status < 500 then the result is final; break retry loop. - if response.status < 500: + # If the response is 404, it might be because of replication lag, so + # keep trying anyway. + if response.status < 500 and response.status != 404: LOGGER.debug('got response %d for %s %s', response.status, conn.req_params['method'], conn.req_params['uri']) break