[MERGE][#148087] Reduce lockdir timeout when running “bzr serve”

Andrew Bennetts andrew at canonical.com
Tue Dec 18 23:06:31 GMT 2007


Hi,

This change simply changes the default lockdir timeout to 0 (rather than 5
minutes) when running “bzr serve”.  This virtually fixes
<https://bugs.launchpad.net/bzr/+bug/148087>.

The problem is if a client attempts to acquire a lock over bzr+ssh, and then is
interrupted, then the “bzr serve” process on the server will not be interrupted
as well.  So if there's a stale lock already, then any future bzr+ssh
connections will leave processes hanging around for up to 5 minutes ready to
acquire the lock.  The typical pattern is something like this sequence, in
fairly quick succession:

  $ bzr push bzr+ssh://...
  Waiting on lock ...
  [User thinks “oh that's stale”, and hits Ctrl-C]
  $ bzr break-lock bzr+ssh://
  [User hits y]
  $ bzr push bzr+ssh://...
  Waiting on lock ...
  [User is baffled]

The final bzr push here waits on a lock because the original push acquired it
after the lock was broken.  That process will probably notice the orignal
connection was broken fairly soon (because it will try to send back an “ok”
response to a now absent client), but by then it's too late: it's acquired the
lock and won't release it on process exit.

Ideally we'd introduce new smart verbs for acquiring locks with non-blocking
semantics, but that won't help existing clients.  So this patch justs change the
existing verbs to be non-blocking.  This means there's no attempts to wait and
retry taking the lock if the first attempt fails, but that's better than the
existing behaviour I think.

This should ameliorate the “stale processes acquiring locks” problem enough that
we can consider bug 148087 fixed.

-Andrew.

-------------- next part --------------
# Bazaar merge directive format 2 (Bazaar 0.90)
# revision_id: andrew.bennetts at canonical.com-20071218225646-\
#   a4i5p1sntsd5tidq
# target_branch: http://bazaar-vcs.org/bzr/bzr.dev
# testament_sha1: 541b94ce2c33e5e19864fe65a4ef0070d952bcef
# timestamp: 2007-12-19 10:02:36 +1100
# source_branch: http://people.ubuntu.com/~andrew/bzr/smart-break-\
#   lock-bug
# base_revision_id: pqm at pqm.ubuntu.com-20071215210020-m28kk1qmbcc9n6qs
# 
# Begin patch
=== modified file 'bzrlib/builtins.py'
--- bzrlib/builtins.py	2007-12-15 16:35:40 +0000
+++ bzrlib/builtins.py	2007-12-18 22:56:46 +0000
@@ -3720,6 +3720,7 @@
         ]
 
     def run(self, port=None, inet=False, directory=None, allow_writes=False):
+        from bzrlib import lockdir
         from bzrlib.smart import medium, server
         from bzrlib.transport import get_transport
         from bzrlib.transport.chroot import ChrootServer
@@ -3750,11 +3751,14 @@
         # be changed with care though, as we dont want to use bandwidth sending
         # progress over stderr to smart server clients!
         old_factory = ui.ui_factory
+        old_lockdir_timeout = lockdir._DEFAULT_TIMEOUT_SECONDS
         try:
             ui.ui_factory = ui.SilentUIFactory()
+            lockdir._DEFAULT_TIMEOUT_SECONDS = 0
             smart_server.serve()
         finally:
             ui.ui_factory = old_factory
+            lockdir._DEFAULT_TIMEOUT_SECONDS = old_lockdir_timeout
 
 
 class cmd_join(Command):

# Begin bundle
IyBCYXphYXIgcmV2aXNpb24gYnVuZGxlIHY0CiMKQlpoOTFBWSZTWcr61FsAAhvfgCRQUWP//3//
//C////wUAT7W80pFnpj1oB5cJKmk0DTSeTUwJhNGJphGE00NqYIDTTTINTUCNGmCekGgDQAAAAA
aNAAlJplDRpqaNU/U9Jkho0aAAADQBhND1BXqp6gaGmhpoAZGRkxAAMhppkAwgJJCAI02kaBpGE0
m1MjSe1Q9JoeoPSBo2iSEcL8YadnP5NX6bm6EzzyuD4Yy7lqOQRodiNcI4o6CbbVyWbTCc5UMEcA
yYHiek6Gdy5ERg5B1BoJKisxuOkDkRNBnXi7UV4JQ/j+E9QvsSFMD8S6N7d+eXa1Veytl41Dmyr5
2HGhvPUdx26z1mvGtSWrEAmPz2xFG0uNzAIPJXVVgMMoFxuA0Y+sybXuDD5TPl0bZV1oKOX/egMB
tWQMNR/NVGZ2zy/BE29hF0dwPzZglIAHee/dQE3U42djlDLIPQl+mJOIqX9PD5q7bZ/HUItqqQR4
m7EPHDxaC1BKmjceVtg6JKiM76fUXygUEnVPS5iJnO86/UHL6AUV6GtfPiDuAIBlhIhXmIBlYNQB
YxTxCZEsxMdK32KsCzNhTbSpKGQok7Nd4axrDZvrNiy+qhgO6w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