From 5b48e48c1a47553ab16eaff8e635884eacb80045 Mon Sep 17 00:00:00 2001 From: "nodir@chromium.org" Date: Fri, 18 Mar 2016 20:27:54 +0000 Subject: [PATCH] Set default --lock_timeout to 5m gclient-sync + git-cache are racy because if two different DEPS files dependent on the same repo URL, even if depsed to different checkout dirs, they use same git cache dir. If both checkout dirs are synced at the same time, one of them cannot acquire a lock. This is a cheap solution to change --lock_timeout option default value from 0 to 5m. R=hinoka@chromium.org BUG=593468 Review URL: https://codereview.chromium.org/1785083005 git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@299386 0039d316-1c4b-4281-b951-d872f2087c98 --- gclient.py | 4 ++-- git_cache.py | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/gclient.py b/gclient.py index 5d0e412a7..c240d4719 100755 --- a/gclient.py +++ b/gclient.py @@ -2050,9 +2050,9 @@ def CMDsync(parser, args): help='Don\'t bootstrap from Google Storage.') parser.add_option('--ignore_locks', action='store_true', help='GIT ONLY - Ignore cache locks.') - parser.add_option('--lock_timeout', type='int', default=0, + parser.add_option('--lock_timeout', type='int', default=5000, help='GIT ONLY - Deadline (in seconds) to wait for git ' - 'cache lock to become available.') + 'cache lock to become available. Default is %default.') (options, args) = parser.parse_args(args) client = GClient.LoadCurrentConfig(options) diff --git a/git_cache.py b/git_cache.py index 9137ef5f5..753ccde34 100755 --- a/git_cache.py +++ b/git_cache.py @@ -93,7 +93,6 @@ class Lockfile(object): """Acquire the lock. This will block with a deadline of self.timeout seconds. - If self.timeout is zero, this is a NON-BLOCKING FAIL-FAST operation. """ elapsed = 0 while True: @@ -102,7 +101,7 @@ class Lockfile(object): return except OSError as e: if elapsed < self.timeout: - sleep_time = min(3, self.timeout - elapsed) + sleep_time = max(10, min(3, self.timeout - elapsed)) logging.info('Could not create git cache lockfile; ' 'will retry after sleep(%d).', sleep_time); elapsed += sleep_time