Stacked-on branch not unlocked when commit_write_group fails on stacked branch

Bug #280608 reported by Jonathan Lange
2
Affects Status Importance Assigned to Milestone
Bazaar
Confirmed
Low
Unassigned

Bug Description

When Repository.commit_write_group fails on a write_locked repo, unlock() will fail to unlock fallback repositories:

This was seen when the failure:

  Module XXX, line YYY, in ZZZ
    branch.pull(source_branch, overwrite=True)
  Module <string>, line 4, in pull_write_locked
  Module bzrlib.branch, line 1931, in pull
    _override_hook_target=_override_hook_target)
  Module <string>, line 4, in pull_write_locked
  Module bzrlib.branch, line 1736, in pull
    graph=graph)
  Module <string>, line 4, in update_revisions_write_locked
  Module bzrlib.branch, line 517, in update_revisions
    self.fetch(other, stop_revision)
  Module <string>, line 4, in fetch_write_locked
  Module bzrlib.branch, line 279, in fetch
    pb=nested_pb)
  Module bzrlib.repository, line 975, in fetch
    find_ghosts=find_ghosts)
  Module <string>, line 4, in fetch_write_locked
  Module bzrlib.repository, line 2762, in fetch
    pb, find_ghosts)
  Module bzrlib.fetch, line 115, in __init__
    self.to_repository.commit_write_group()
  Module bzrlib.repository, line 942, in commit_write_group
    self._commit_write_group()
  Module bzrlib.repofmt.pack_repo, line 1794, in _commit_write_group
    return self._pack_collection._commit_write_group()
  Module bzrlib.repofmt.pack_repo, line 1643, in _commit_write_group
    if not self.autopack():
  Module bzrlib.repofmt.pack_repo, line 1209, in autopack
    self._execute_pack_operations(pack_operations)
  Module bzrlib.repofmt.pack_repo, line 1223, in _execute_pack_operations
    _packer_class(self, packs, '.autopack').pack()
  Module bzrlib.repofmt.pack_repo, line 585, in pack
    return self._create_pack_from_packs()
  Module bzrlib.repofmt.pack_repo, line 734, in _create_pack_from_packs
    self._check_references()
  Module bzrlib.repofmt.pack_repo, line 696, in _check_references
    missing_file_id)
RevisionNotPresent: Revision {<email address hidden>} not present in "source-20060927072757-wtb45rxgrsx81hqv-1".

Caused the following warning:

bzrlib/lockable_files.py:116: UserWarning: LockableFiles(<TransportElided url=/~launchpad-pqm/launchpad/devel/.bzr/repository>) was gc'd while locked
  warnings.warn("%r was gc'd while locked" % self)

lifeless has provided the following patch:
=== modified file 'bzrlib/repository.py'
--- bzrlib/repository.py 2008-10-09 04:50:37 +0000
+++ bzrlib/repository.py 2008-10-09 06:37:21 +0000
@@ -1027,9 +1027,12 @@
             self.control_files._lock_mode == 'w'):
             if self._write_group is not None:
                 self.abort_write_group()
- self.control_files.unlock()
+ self._unlock()
                 raise errors.BzrError(
                      'Must end write groups before releasing write locks.')
+ self._unlock()
+
+ def _unlock(self):
         self.control_files.unlock()
         for repo in self._fallback_repositories:
             repo.unlock()

Revision history for this message
Martin Pool (mbp) wrote :

The patch looks reasonable to me.

description: updated
Changed in bzr:
importance: Undecided → Medium
status: New → Confirmed
Revision history for this message
Martin Pool (mbp) wrote :

As it has an implicit +1 from lifeless I'll send this to pqm.

I think this is just cosmetic as losing the lock at this point will not leave the repositories physically locked.

Revision history for this message
Martin Pool (mbp) wrote :

This patch causes a test failure.

Andrew Bennetts (spiv)
tags: added: stacking
removed: stack
Martin Pool (mbp)
Changed in bzr:
status: Confirmed → In Progress
assignee: nobody → Martin Pool (mbp)
Martin Pool (mbp)
Changed in bzr:
assignee: Martin Pool (mbp) → nobody
importance: Medium → Low
status: In Progress → Confirmed
Jelmer Vernooij (jelmer)
tags: added: check-for-breezy
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.