Commit 5b48e48c authored by nodir@chromium.org's avatar nodir@chromium.org

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
parent b1200846
...@@ -2050,9 +2050,9 @@ def CMDsync(parser, args): ...@@ -2050,9 +2050,9 @@ def CMDsync(parser, args):
help='Don\'t bootstrap from Google Storage.') help='Don\'t bootstrap from Google Storage.')
parser.add_option('--ignore_locks', action='store_true', parser.add_option('--ignore_locks', action='store_true',
help='GIT ONLY - Ignore cache locks.') 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 ' 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) (options, args) = parser.parse_args(args)
client = GClient.LoadCurrentConfig(options) client = GClient.LoadCurrentConfig(options)
......
...@@ -93,7 +93,6 @@ class Lockfile(object): ...@@ -93,7 +93,6 @@ class Lockfile(object):
"""Acquire the lock. """Acquire the lock.
This will block with a deadline of self.timeout seconds. 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 elapsed = 0
while True: while True:
...@@ -102,7 +101,7 @@ class Lockfile(object): ...@@ -102,7 +101,7 @@ class Lockfile(object):
return return
except OSError as e: except OSError as e:
if elapsed < self.timeout: 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; ' logging.info('Could not create git cache lockfile; '
'will retry after sleep(%d).', sleep_time); 'will retry after sleep(%d).', sleep_time);
elapsed += sleep_time elapsed += sleep_time
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment