AssertionError about history length in set_last_revision_info

Bug #241170 reported by cyli
2
Affects Status Importance Assigned to Milestone
Bazaar
Fix Released
High
Andrew Bennetts

Bug Description

I have a bound branch that I'm trying to commit to, and when I do I get an assertion error. I also tried committing locally, which worked, and then pushing, which yielded the same error. The client bzr version is 1.5 and the server is 0.90.

Revision history for this message
cyli (cyli) wrote :
Revision history for this message
Andrew Bennetts (spiv) wrote :

It appears the client and server disagree about how long the history of that revision should be. What does "bzr ancestry" for that branch report locally and when run on the server?

I suspect running "bzr upgrade" and/or "bzr reconcile" on the server will fix this.

Revision history for this message
cyli (cyli) wrote :
Download full text (4.0 KiB)

Hm... that is odd. It was a fresh checkout, which I then made some small changes to and tried to commit.

"bzr ancestry" locally:
cyli@jinchuuriki-20080527230444-hbxas6yrzjng3vcn
cyli@jinchuuriki-20080527230729-9frniooeex8roncb
cyli@jinchuuriki-20080528040545-9e1ivprfkw3vy4ou
cyli@jinchuuriki-20080528043359-g0md7adzc1yfeo3x
cyli@legion-20080530200003-3kt65zc9yjaxej67
cyli@jinchuuriki-20080618141543-2hq42qg2ep9xy880
<email address hidden>

"bzr ancestry" on the server:
cyli@jinchuuriki-20080527230444-hbxas6yrzjng3vcn
cyli@jinchuuriki-20080527230729-9frniooeex8roncb
cyli@jinchuuriki-20080528040545-9e1ivprfkw3vy4ou
cyli@jinchuuriki-20080528043359-g0md7adzc1yfeo3x
cyli@legion-20080530200003-3kt65zc9yjaxej67

(I tried to commit first, and then tried to commit locally and do a push).

The results of "bzr upgrade":
bzr: ERROR: The branch format Bazaar-NG meta directory, format 1 is already at the most recent format.

The results of "bzr reconcile":
Reconciling branch file:///Users/cyli/Projects/wordnumbers/
revision_history ok.
Reconciling repository file:///Users/cyli/Projects/wordnumbers/
Reconciliation complete.

That seemed ok, but then I tried to run "bzr push" again and:
Using saved location: bzr+ssh://legion/home/cyli/Tonkatsu/Projects/wordnumbers/
This transport does not update the working tree of: bzr+ssh://legion/home/cyli/Tonkatsu/Projects/wordnumbers/. See 'bzr help working-trees' for more information.
Server is too old for fast get_parent_map, reconnecting. (Upgrade the server to Bazaar 1.2 to avoid this)
bzr: ERROR: exceptions.AssertionError: 6 != 7

Traceback (most recent call last):
  File "/Library/Python/2.5/site-packages/bzrlib/commands.py", line 846, in run_bzr_catch_errors
    return run_bzr(argv)
  File "/Library/Python/2.5/site-packages/bzrlib/commands.py", line 797, in run_bzr
    ret = run(*run_argv)
  File "/Library/Python/2.5/site-packages/bzrlib/commands.py", line 499, in run_argv_aliases
    return self.run(**all_cmd_args)
  File "/Library/Python/2.5/site-packages/bzrlib/builtins.py", line 856, in run
    stop_revision=revision_id)
  File "/Library/Python/2.5/site-packages/bzrlib/decorators.py", line 127, in read_locked
    return unbound(self, *args, **kwargs)
  File "/Library/Python/2.5/site-packages/bzrlib/branch.py", line 1612, in push
    _override_hook_source_branch=_override_hook_source_branch)
  File "/Library/Python/2.5/site-packages/bzrlib/branch.py", line 1654, in _push_with_bound_branches
    result = self._basic_push(target, overwrite, stop_revision)
  File "/Library/Python/2.5/site-packages/bzrlib/branch.py", line 1673, in _basic_push
    target.update_revisions(self, stop_revision)
  File "/Library/Python/2.5/site-packages/bzrlib/remote.py", line 1537, in update_revisions
    other, stop_revision=stop_revision, overwrite=overwrite)
  File "/Library/Python/2.5/site-packages/bzrlib/decorators.py", line 165, in write_locked
    return unbound(self, *args, **kwargs)
  File "/Library/Python/2.5/site-packages/bzrlib/branch.py", line 1536, in update_revisions
    other_last_revision)
  File "/Library/Python/2.5/site-packages/bzrlib/decorators.py", line 165, in write_locked
    r...

Read more...

Revision history for this message
cyli (cyli) wrote :

Whoops, sorry to mention a step. I ran "bzr upgrade" on both the server and locally - the message above was the local result, and basically the same happened on the server:
Reconciling repository file:///home/cyli/Tonkatsu/Projects/wordnumbers/
Inventory ok.
Reconciliation complete.

"bzr push" from the client resulted in the same error in both cases.

Revision history for this message
John A Meinel (jameinel) wrote :

Out of curiousity, is your local repository a pack-0.92 repository, and the remote one a knit/dirstate repository? (bzr info should tell you)

I'm guessing the problem is that the remote repository is missing revisions:
cyli@jinchuuriki-20080618141543-2hq42qg2ep9xy880
<email address hidden>

At least the first, I don't know about the second.

You can try forcing a copy with:

bzr push -r revid:cyli@jinchuuriki-20080618141543-2hq42qg2ep9xy880

Can you try that, and then see if a plain "bzr push" works?

Revision history for this message
cyli (cyli) wrote :
Download full text (3.3 KiB)

My local repository is indeed a pack-0.92 and the remote one a dirstate repository.

And it's odd that there would be a revision the server didn't know about. =/ This is a new machine, so it's a fresh checkout and this is the first commit I've made locally. And no one else is working on the code or anything, just me.

Anyhoo... the results of "bzr push -r revid:cyli@jinchuuriki-20080618141543-2hq42qg2ep9xy880" and then a "bzr push":

jinchuuriki:wordnumbers cyli$ bzr push
Using saved location: bzr+ssh://legion/home/cyli/Tonkatsu/Projects/wordnumbers/
This transport does not update the working tree of: bzr+ssh://legion/home/cyli/Tonkatsu/Projects/wordnumbers/. See 'bzr help working-trees' for more information.
Server is too old for fast get_parent_map, reconnecting. (Upgrade the server to Bazaar 1.2 to avoid this)
bzr: ERROR: exceptions.AssertionError: 6 != 7

Traceback (most recent call last):
  File "/Library/Python/2.5/site-packages/bzrlib/commands.py", line 846, in run_bzr_catch_errors
    return run_bzr(argv)
  File "/Library/Python/2.5/site-packages/bzrlib/commands.py", line 797, in run_bzr
    ret = run(*run_argv)
  File "/Library/Python/2.5/site-packages/bzrlib/commands.py", line 499, in run_argv_aliases
    return self.run(**all_cmd_args)
  File "/Library/Python/2.5/site-packages/bzrlib/builtins.py", line 856, in run
    stop_revision=revision_id)
  File "/Library/Python/2.5/site-packages/bzrlib/decorators.py", line 127, in read_locked
    return unbound(self, *args, **kwargs)
  File "/Library/Python/2.5/site-packages/bzrlib/branch.py", line 1612, in push
    _override_hook_source_branch=_override_hook_source_branch)
  File "/Library/Python/2.5/site-packages/bzrlib/branch.py", line 1654, in _push_with_bound_branches
    result = self._basic_push(target, overwrite, stop_revision)
  File "/Library/Python/2.5/site-packages/bzrlib/branch.py", line 1673, in _basic_push
    target.update_revisions(self, stop_revision)
  File "/Library/Python/2.5/site-packages/bzrlib/remote.py", line 1537, in update_revisions
    other, stop_revision=stop_revision, overwrite=overwrite)
  File "/Library/Python/2.5/site-packages/bzrlib/decorators.py", line 165, in write_locked
    return unbound(self, *args, **kwargs)
  File "/Library/Python/2.5/site-packages/bzrlib/branch.py", line 1536, in update_revisions
    other_last_revision)
  File "/Library/Python/2.5/site-packages/bzrlib/decorators.py", line 165, in write_locked
    return unbound(self, *args, **kwargs)
  File "/Library/Python/2.5/site-packages/bzrlib/branch.py", line 1452, in set_last_revision_info
    raise AssertionError('%d != %d' % (len(history), revno))
AssertionError: 6 != 7

bzr 1.5 on python 2.5.1 (darwin)
arguments: ['/usr/local/bin/bzr', 'push']
encoding: 'UTF-8', fsenc: 'utf-8', lang: 'en_US.UTF-8'
plugins:
  bzrtools /Library/Python/2.5/site-packages/bzrlib/plugins/bzrtools [1.5.0]
  launchpad /Library/Python/2.5/site-packages/bzrlib/plugins/launchpad [unknown]
  qbzr /Library/Python/2.5/site-packages/bzrlib/plugins/qbzr [0.9.0]
  rebase /Library/Python/2.5/site-packages/bzrlib/plugins/rebase [0.3.0dev0]
*** Bazaar has encountered ...

Read more...

Revision history for this message
cyli (cyli) wrote :

I eventually just copied over my changed files and commited them on the server. I deleted my local repository, and re-checked out all the code. I made some changes, tried to commit them, and basically got the same error except that the revision numbers have changed from 6 and 7 to 7 and 8:

Committing to: bzr+ssh://legion/home/cyli/Tonkatsu/Projects/wordnumbers/
modified testWordnumber.py
modified wordnumber.py
Server is too old for fast get_parent_map, reconnecting. (Upgrade the server to Bazaar 1.2 to avoid this)
bzr: ERROR: exceptions.AssertionError: 7 != 8

.... etc. etc. same errors as above basically.

Revision history for this message
cyli (cyli) wrote :

To see if it was just that my repository was broken, I started a new repository on the same server in an empty directory with "bzr init". Then I added a file and committed. Locally, I did a "bzr checkout" via bzr+ssh, changed the file, and did "bzr commit". And I basically get the same error with AssertionError 1 != 2.

Revision history for this message
Andrew Bennetts (spiv) wrote :

That's pretty weird. John, do you have any idea why this would happen?

Revision history for this message
cyli (cyli) wrote :
Download full text (3.7 KiB)

So full details of what I did are here (apologies for seeming to beat this into the ground, but I thought my general description may not have been very clear):

Server:
cyli@legion:~$ mkdir Temp
cyli@legion:~$ cd Temp
cyli@legion:~/Temp$ bzr init
cyli@legion:~/Temp$ echo hello > hello.txt
cyli@legion:~/Temp$ bzr add hello.txt
added hello.txt
cyli@legion:~/Temp$ bzr commit -m "added hello.txt"
added hello.txt
Committed revision 1.
cyli@legion:~/Temp$ bzr ancestry
cyli@legion-20080708070158-avaluy8zhfg6j45x

Local:
jinchuuriki:~ cyli$ mkdir Temp
jinchuuriki:~ cyli$ cd Temp
jinchuuriki:Temp cyli$ bzr checkout bzr+ssh://legion/home/cyli/Temp .
Server is too old for fast get_parent_map, reconnecting. (Upgrade the server to Bazaar 1.2 to avoid this)
jinchuuriki:Temp cyli$ bzr ancestry
cyli@legion-20080708070158-avaluy8zhfg6j45x
jinchuuriki:Temp cyli$ echo "hello again" >> hello.txt
jinchuuriki:Temp cyli$ bzr status
modified:
  hello.txt
jinchuuriki:Temp cyli$ bzr commit -m "changed hello.txt"
Committing to: bzr+ssh://legion/home/cyli/Temp/
modified hello.txt
Server is too old for fast get_parent_map, reconnecting. (Upgrade the server to Bazaar 1.2 to avoid this)
bzr: ERROR: exceptions.AssertionError: 1 != 2

Traceback (most recent call last):
  File "/Library/Python/2.5/site-packages/bzrlib/commands.py", line 846, in run_bzr_catch_errors
    return run_bzr(argv)
  File "/Library/Python/2.5/site-packages/bzrlib/commands.py", line 797, in run_bzr
    ret = run(*run_argv)
  File "/Library/Python/2.5/site-packages/bzrlib/commands.py", line 499, in run_argv_aliases
    return self.run(**all_cmd_args)
  File "/Library/Python/2.5/site-packages/bzrlib/builtins.py", line 2364, in run
    author=author)
  File "/Library/Python/2.5/site-packages/bzrlib/decorators.py", line 165, in write_locked
    return unbound(self, *args, **kwargs)
  File "/Library/Python/2.5/site-packages/bzrlib/workingtree_4.py", line 240, in commit
    result = WorkingTree3.commit(self, message, revprops, *args, **kwargs)
  File "/Library/Python/2.5/site-packages/bzrlib/decorators.py", line 165, in write_locked
    return unbound(self, *args, **kwargs)
  File "/Library/Python/2.5/site-packages/bzrlib/mutabletree.py", line 197, in commit
    revprops=revprops, *args, **kwargs)
  File "/Library/Python/2.5/site-packages/bzrlib/commit.py", line 392, in commit
    self.rev_id)
  File "/Library/Python/2.5/site-packages/bzrlib/decorators.py", line 165, in write_locked
    return unbound(self, *args, **kwargs)
  File "/Library/Python/2.5/site-packages/bzrlib/remote.py", line 1511, in set_last_revision_info
    return self._real_branch.set_last_revision_info(revno, revision_id)
  File "/Library/Python/2.5/site-packages/bzrlib/decorators.py", line 165, in write_locked
    return unbound(self, *args, **kwargs)
  File "/Library/Python/2.5/site-packages/bzrlib/branch.py", line 1456, in set_last_revision_info
    raise AssertionError('%d != %d' % (len(history), revno))
AssertionError: 1 != 2

bzr 1.5 on python 2.5.1 (darwin)
arguments: ['/usr/local/bin/bzr', 'commit', '-m', 'changed hello.txt']
encoding: 'UTF-8', fsenc: 'utf-8', lang: 'en_US.UTF-8'
plugins:
  bzrtools /Library/Python/...

Read more...

Revision history for this message
cyli (cyli) wrote :

Here is the .bzr.log after running bzr -Dhpss checkout bzr+ssh://legion/home/cyli/Temp .

Revision history for this message
cyli (cyli) wrote :

Here is the .bzr.log after running bzr -Dhpss commit -m "changed hello.txt" (cleared old log)

Revision history for this message
Andrew Bennetts (spiv) wrote :

We did some debugging on IRC. The problem is reproducible with a 0.90 server and 0.15 client, and a format 5 (bzr init --dirstate) branch on the server.

To cut a long story short, the root cause is a bug in RemoteRepository._get_parent_map. The "except UnknownSmartMethod" block doesn't adjust the result of self.get_revision_graph() for the subtly different get_parent_map API. That causes BzrBranch._lefthand_history to see revision 1's parents as () rather than (NULL_REVISION,), which causes it to cut the history short by one, which causes the assertion.

Changed in bzr:
assignee: nobody → spiv
importance: Undecided → High
milestone: none → 1.6
status: New → Confirmed
Revision history for this message
Andrew Bennetts (spiv) wrote :

For anyone else that has this bug, a workaround is to upgrade the branch on the server to format 6, by running "bzr upgrade --dirstate-tags" in that directory the server.

Martin Pool (mbp)
Changed in bzr:
milestone: 1.6 → none
Martin Pool (mbp)
summary: - Assertion error when trying to push
+ AssertionError about history length in set_last_revision_info
Revision history for this message
Martin Pool (mbp) wrote :

I'll mark this fixed, probably in 1.6. If not, upgrading will fix it.

Changed in bzr:
status: Confirmed → Fix Released
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.