corrupt inventory deltas are not detected by dirstate

Bug #150438 reported by Martin Pool
86
Affects Status Importance Assigned to Milestone
Bazaar
Fix Released
High
Robert Collins

Bug Description

AssertionError: Could not find target parent in wt: sales-demos/site1
parent of: (('sales-demos/site1', 'movie_sound.html', 'movie_sound.html-20070914001414-1qgh8i8htph5b09r-4'), [('f', '148368181de9b4f9fe158dd3a863abccd408a342', 1674L, 0, 'AAAGikbp0cxG6dHMAAAIAQAvwfsAAIGk'), ('r', 'site1/movie_sound.html', 0L, 0, '')])

After 'bzr rm' of a file that is absent, or after a commit that auto-removed a subtree.

The root cause of the corruption is that the dirstate is being left in a state where _validate() will fail because there is a path (e.g. a/b) that is marked present, but the parent (a) is marked absent.

Tags: dirstate

Related branches

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

It would be useful to know what actions lead up to this failure.

Revision history for this message
Martin Pool (mbp) wrote :
Download full text (3.9 KiB)

I think <wildfire> also hit this:

bzr: ERROR: exceptions.AssertionError: Could not find target parent in wt: blosxom
parent of: (('blosxom', 'blosxom.conf', 'blosxom.conf-20080404015720-i5s5yes7kvrl8bsg-416'), [('f', '1c992d92d166077ecacc4eca5672cb03a1c08880', 2386L, 0, 'AAAJUkazAKhHzgoWAAAIAQBxgBoAAIGk'), ('f', '1c992d92d166077ecacc4eca5672cb03a1c08880', 2386L, 0, 'root@muspell-20080404015800-i9u794mhs2i8irh0')])

Traceback (most recent call last):
  File "/usr/lib/python2.5/site-packages/bzrlib/commands.py", line 834, in run_bzr_catch_errors
    return run_bzr(argv)
  File "/usr/lib/python2.5/site-packages/bzrlib/commands.py", line 790, in run_bzr
    ret = run(*run_argv)
  File "/usr/lib/python2.5/site-packages/bzrlib/commands.py", line 492, in run_argv_aliases
    return self.run(**all_cmd_args)
  File "/usr/lib/python2.5/site-packages/bzrlib/plugins/interactive/__init__.py", line 121, in run
    message=message, **kw)
  File "/usr/lib/python2.5/site-packages/bzrlib/builtins.py", line 2355, in run
    author=author)
  File "/usr/lib/python2.5/site-packages/bzrlib/decorators.py", line 165, in write_locked
    return unbound(self, *args, **kwargs)
  File "/usr/lib/python2.5/site-packages/bzrlib/workingtree_4.py", line 246, in commit
    result = WorkingTree3.commit(self, message, revprops, *args, **kwargs)
  File "/usr/lib/python2.5/site-packages/bzrlib/decorators.py", line 165, in write_locked
    return unbound(self, *args, **kwargs)
  File "/usr/lib/python2.5/site-packages/bzrlib/mutabletree.py", line 187, in commit
    revprops=revprops, *args, **kwargs)
  File "/usr/lib/python2.5/site-packages/bzrlib/commit.py", line 367, in commit
    message = message_callback(self)
  File "/usr/lib/python2.5/site-packages/bzrlib/builtins.py", line 2335, in get_message
    output_encoding=bzrlib.user_encoding)
  File "/usr/lib/python2.5/site-packages/bzrlib/msgeditor.py", line 259, in make_commit_message_template_encoded
    template = make_commit_message_template(working_tree, specific_files)
  File "/usr/lib/python2.5/site-packages/bzrlib/msgeditor.py", line 241, in make_commit_message_template
    to_file=status_tmp)
  File "/usr/lib/python2.5/site-packages/bzrlib/status.py", line 114, in show_tree_status
    want_unversioned=want_unversioned)
  File "/usr/lib/python2.5/site-packages/bzrlib/tree.py", line 93, in changes_from
    want_unversioned=want_unversioned,
  File "/usr/lib/python2.5/site-packages/bzrlib/decorators.py", line 127, in read_locked
    return unbound(self, *args, **kwargs)
  File "/usr/lib/python2.5/site-packages/bzrlib/tree.py", line 727, in compare
    want_unversioned=want_unversioned)
  File "/usr/lib/python2.5/site-packages/bzrlib/delta.py", line 217, in _compare_trees
    want_unversioned=want_unversioned):
  File "/usr/lib/python2.5/site-packages/bzrlib/workingtree_4.py", line 2370, in iter_changes
    result = _process_entry(current_entry, current_path_info)
  File "/usr/lib/python2.5/site-packages/bzrlib/workingtree_4.py", line 2076, in _process_entry
    % (new_dirname, entry))
AssertionError: Could not find target parent in wt: blosxom
parent of: (('blosxom', 'blosxom.co...

Read more...

Changed in bzr:
importance: Medium → High
Revision history for this message
Martin Pool (mbp) wrote :

12:50 <wildfire> poolie, progsoc is using bzr to manage /etc on a few machines; I did a 'dpkg -P
                 blosxom' which also removed the /etc/blosxom directory
12:51 <wildfire> poolie, I then wanted to commit that directory removal, so I did "bzr commit blosxom"
                 and from this point onwards bzr is failing with an internal error on a number of
                 commands

Changed in bzr:
status: Incomplete → Confirmed
Revision history for this message
Martin Pool (mbp) wrote :

Trying to branch the failed directory also fails -- there may be a problem in the committed revision that prevents extracting it:

wildfire@muspell:/etc$ sudo bzr branch /etc /tmp/new-etc
bzr: ERROR: exceptions.AssertionError: Could not find target parent in wt: blosxom
parent of: (('blosxom', 'blosxom.conf', 'blosxom.conf-20080404015720-i5s5yes7kvrl8bsg-416'), [('f', '1c992d92d166077ecacc4eca5672cb03a1c08880', 2386L, 0, 'AAAJUkazAKhHzgoWAAAIAQBxgBoAAIGk'), ('f', '1c992d92d166077ecacc4eca5672cb03a1c08880', 2386L, 0, 'root@muspell-20080404015800-i9u794mhs2i8irh0')])

Traceback (most recent call last):
  File "/usr/lib/python2.5/site-packages/bzrlib/commands.py", line 834, in run_bzr_catch_errors
    return run_bzr(argv)
  File "/usr/lib/python2.5/site-packages/bzrlib/commands.py", line 790, in run_bzr
    ret = run(*run_argv)
  File "/usr/lib/python2.5/site-packages/bzrlib/commands.py", line 492, in run_argv_aliases
    return self.run(**all_cmd_args)
  File "/usr/lib/python2.5/site-packages/bzrlib/builtins.py", line 927, in run
    hardlink=hardlink)
  File "/usr/lib/python2.5/site-packages/bzrlib/bzrdir.py", line 957, in sprout
    hardlink=hardlink)
  File "/usr/lib/python2.5/site-packages/bzrlib/bzrdir.py", line 1242, in create_workingtree
    accelerator_tree=accelerator_tree, hardlink=hardlink)
  File "/usr/lib/python2.5/site-packages/bzrlib/workingtree_4.py", line 1358, in initialize
    hardlink=hardlink)
  File "/usr/lib/python2.5/site-packages/bzrlib/transform.py", line 1494, in build_tree
    return _build_tree(tree, wt, accelerator_tree, hardlink)
  File "/usr/lib/python2.5/site-packages/bzrlib/transform.py", line 1584, in _build_tree
    accelerator_tree, hardlink)
  File "/usr/lib/python2.5/site-packages/bzrlib/transform.py", line 1613, in _create_files
    in iter if not (c or e[0] != e[1]))
  File "/usr/lib/python2.5/site-packages/bzrlib/transform.py", line 1612, in <genexpr>
    unchanged = dict((f, p[1]) for (f, p, c, v, d, n, k, e)
  File "/usr/lib/python2.5/site-packages/bzrlib/workingtree_4.py", line 2332, in iter_changes
    result = _process_entry(current_entry, None)
  File "/usr/lib/python2.5/site-packages/bzrlib/workingtree_4.py", line 2076, in _process_entry
    % (new_dirname, entry))
AssertionError: Could not find target parent in wt: blosxom
parent of: (('blosxom', 'blosxom.conf', 'blosxom.conf-20080404015720-i5s5yes7kvrl8bsg-416'), [('f', '1c992d92d166077ecacc4eca5672cb03a1c08880', 2386L, 0, 'AAAJUkazAKhHzgoWAAAIAQBxgBoAAIGk'), ('f', '1c992d92d166077ecacc4eca5672cb03a1c08880', 2386L, 0, 'root@muspell-20080404015800-i9u794mhs2i8irh0')])

bzr 1.3.1rc1 on python 2.5.1.final.0 (linux2)
arguments: ['/usr/bin/bzr', 'branch', '/etc', '/tmp/new-etc']
encoding: 'UTF-8', fsenc: 'UTF-8', lang: 'en_AU.UTF-8'
plugins:
  email /usr/lib/python2.5/site-packages/bzrlib/plugins/email [unknown]
  launchpad /usr/lib/python2.5/site-packages/bzrlib/plugins/launchpad [unknown]
*** Bazaar has encountered an internal error.

Revision history for this message
Gregor Müllegger (gregor-muellegger) wrote :
Download full text (3.4 KiB)

This Error also occurs on my machine:

phxx@tinkyra:~/projects/rpg/trunk/test$ bzr st
bzr: ERROR: exceptions.AssertionError: Could not find target parent in wt: test/test_rpg
parent of: (('test/test_rpg', '__init__.py', '__init__.py-20080229141146-kku1k78xed8uu1ux-138'), [('f', 'da39a3ee5e6b4b0d3255bfef95601890afd80709', 0L, 0, 'AAAAAEgHobFIB6GxAAAIBABcxNkAAIGk'), ('f', 'da39a3ee5e6b4b0d3255bfef95601890afd80709', 0L, 0, '<email address hidden>')])

Traceback (most recent call last):
  File "/usr/lib/python2.5/site-packages/bzrlib/commands.py", line 834, in run_bzr_catch_errors
    return run_bzr(argv)
  File "/usr/lib/python2.5/site-packages/bzrlib/commands.py", line 790, in run_bzr
    ret = run(*run_argv)
  File "/usr/lib/python2.5/site-packages/bzrlib/commands.py", line 492, in run_argv_aliases
    return self.run(**all_cmd_args)
  File "/usr/lib/python2.5/site-packages/bzrlib/commands.py", line 800, in ignore_pipe
    result = func(*args, **kwargs)
  File "/usr/lib/python2.5/site-packages/bzrlib/builtins.py", line 189, in run
    to_file=self.outf, short=short, versioned=versioned)
  File "/usr/lib/python2.5/site-packages/bzrlib/status.py", line 114, in show_tree_status
    want_unversioned=want_unversioned)
  File "/usr/lib/python2.5/site-packages/bzrlib/tree.py", line 93, in changes_from
    want_unversioned=want_unversioned,
  File "/usr/lib/python2.5/site-packages/bzrlib/decorators.py", line 127, in read_locked
    return unbound(self, *args, **kwargs)
  File "/usr/lib/python2.5/site-packages/bzrlib/tree.py", line 727, in compare
    want_unversioned=want_unversioned)
  File "/usr/lib/python2.5/site-packages/bzrlib/delta.py", line 217, in _compare_trees
    want_unversioned=want_unversioned):
  File "/usr/lib/python2.5/site-packages/bzrlib/workingtree_4.py", line 2332, in iter_changes
    result = _process_entry(current_entry, None)
  File "/usr/lib/python2.5/site-packages/bzrlib/workingtree_4.py", line 2076, in _process_entry
    % (new_dirname, entry))
AssertionError: Could not find target parent in wt: test/test_rpg
parent of: (('test/test_rpg', '__init__.py', '__init__.py-20080229141146-kku1k78xed8uu1ux-138'), [('f', 'da39a3ee5e6b4b0d3255bfef95601890afd80709', 0L, 0, 'AAAAAEgHobFIB6GxAAAIBABcxNkAAIGk'), ('f', 'da39a3ee5e6b4b0d3255bfef95601890afd80709', 0L, 0, '<email address hidden>')])

bzr 1.3.1rc1 on python 2.5.1.final.0 (linux2)
arguments: ['/usr/bin/bzr', 'st']
encoding: 'UTF-8', fsenc: 'UTF-8', lang: 'de_DE.UTF-8'
plugins:
  bzrtools /usr/lib/python2.5/site-packages/bzrlib/plugins/bzrtools [1.3.0]
  gtk /usr/lib/python2.5/site-packages/bzrlib/plugins/gtk [0.93.0]
  launchpad /usr/lib/python2.5/site-packages/bzrlib/plugins/launchpad [unknown]
  svn /usr/lib/python2.5/site-packages/bzrlib/plugins/svn [0.4.9]
*** Bazaar has encountered an internal error.
    Please report a bug at https://bugs.launchpad.net/bzr/+filebug
    including this traceback, and a description of what you
    were doing when the error occurred.

I have done before a refactoring of the brunch.
There also passes a few athor "bzr st" withou...

Read more...

Revision history for this message
Berix (justloop) wrote :
Download full text (3.6 KiB)

I use bzr to version my home directory. About a week ago, I started getting "AssertionError: Could not find target parent in wt:" errors on most operations, including status, check, etc. Ignore and remove do not throw the same error. I use similar versioning for /etc directory without problems.

By the time I encountered the error, at least several days had passed since the last known error-free bzr usage. Therefore I am not sure what might have caused it.

My best guess (based on the error trace below) is the directory "K&R" which I had created using the eclipse IDE. While the "&" didn't cause a problem within eclipse, maybe bzr was unable to handle it correctly when I did a mass add/commit. Since then I deleted the "K&R" directory in the file system, added its parent (~/Documents/workspace) to bzr ignore and removed from the tree, but I still get the error.

$ bzr status
bzr: ERROR: exceptions.AssertionError: Could not find target parent in wt: Documents/workspace
parent of: (('Documents/workspace', 'K&R', 'kr-20080331143609-k20y6sirzisq1rmm-6'), [('d', '', 0L, 0, 'AAAQAEfw2oNH8PUeAAADQQBBoKoAAEHt'), ('d', '', 0L, 0, 'yavuz@boris-20080331143701-m2pig87drngzxruo')])

Traceback (most recent call last):
  File "/usr/lib/python2.5/site-packages/bzrlib/commands.py", line 834, in run_bzr_catch_errors
    return run_bzr(argv)
  File "/usr/lib/python2.5/site-packages/bzrlib/commands.py", line 790, in run_bzr
    ret = run(*run_argv)
  File "/usr/lib/python2.5/site-packages/bzrlib/commands.py", line 492, in run_argv_aliases
    return self.run(**all_cmd_args)
  File "/usr/lib/python2.5/site-packages/bzrlib/commands.py", line 800, in ignore_pipe
    result = func(*args, **kwargs)
  File "/usr/lib/python2.5/site-packages/bzrlib/builtins.py", line 189, in run
    to_file=self.outf, short=short, versioned=versioned)
  File "/usr/lib/python2.5/site-packages/bzrlib/status.py", line 114, in show_tree_status
    want_unversioned=want_unversioned)
  File "/usr/lib/python2.5/site-packages/bzrlib/tree.py", line 93, in changes_from
    want_unversioned=want_unversioned,
  File "/usr/lib/python2.5/site-packages/bzrlib/decorators.py", line 127, in read_locked
    return unbound(self, *args, **kwargs)
  File "/usr/lib/python2.5/site-packages/bzrlib/tree.py", line 727, in compare
    want_unversioned=want_unversioned)
  File "/usr/lib/python2.5/site-packages/bzrlib/delta.py", line 217, in _compare_trees
    want_unversioned=want_unversioned):
  File "/usr/lib/python2.5/site-packages/bzrlib/workingtree_4.py", line 2332, in iter_changes
    result = _process_entry(current_entry, None)
  File "/usr/lib/python2.5/site-packages/bzrlib/workingtree_4.py", line 2076, in _process_entry
    % (new_dirname, entry))
AssertionError: Could not find target parent in wt: Documents/workspace
parent of: (('Documents/workspace', 'K&R', 'kr-20080331143609-k20y6sirzisq1rmm-6'), [('d', '', 0L, 0, 'AAAQAEfw2oNH8PUeAAADQQBBoKoAAEHt'), ('d', '', 0L, 0, 'yavuz@boris-20080331143701-m2pig87drngzxruo')])

bzr 1.3.1 on python 2.5.2.final.0 (linux2)
arguments: ['/usr/bin/bzr', 'status']
encoding: 'UTF-8', fsenc: 'UTF-8', lang: 'en_US.UTF-8'
plugins:
  bzrtools /usr/lib/python2.5/sit...

Read more...

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

Berix, I think it is actually complaining about not being able to find the "parent" directory, namely "Documents/workspace" not "K&R" itself. Have you done anything odd with that directory?

If you are using Eclipse, are you using the bzr-eclipse plugin? I'm curious if it might have added something without adding its parent directory.

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

krow on IRC just ran into this.
He said that he did a plain "rm -rf directory" without informing bzr. And then when it came time to "bzr commit" bzr failed with this error.

Revision history for this message
Adam Olsen (rhamph) wrote :

Courtesy of bash's "history" command, an abridged log of me running into this bug - and finding a workaround.

  815 bzr merge ../3.0
  816 bzr conflicts --help
  817 bzr conflicts
3.0 had deleted Mac/Modules. I had some conflicts though, so bzr didn't delete my copy yet.

  841 ls Mac/Modules/
  842 cd Mac/Modules/
  843 bzr conflicts
  844 bzr conflicts .
  845 ls
  846 gvim *
  847 bzr diff MacOS.c.* | less
  848 diff -u MacOS.c.* | less
  849 diff -u icgluemodule.c.* | less
  850 diff -u Nav.c.* | less
  851 rm *
  852 cd ../..
  853 bzr conflicts
  854 bzr remove Mac/Modules/
I believe this succeeded, removing the dir.

  855 bzr conflicts
  856 bzr resolve mac/Modules
  857 bzr resolve Mac/Modules
  858 bzr conflicts
  859 bzr resolve Mac/Modules/Macos.c
  860 bzr resolve Mac/Modules/MacOS.c
  861 bzr resolve Mac/Modules/Nav.c
  862 bzr resolve Mac/Modules/icgluemodule.c
  863 bzr conflicts
Finally get it all resolved.

  933 bzr diff | diffstat
Uh oh.. repository is hosed.. some mention of Mac/Modules not having its parent.. searched for and found this bug report..

  934 bzr diff
  935 bzr --help
  936 mkdir Mac/Modules
  937 bzr diff | less
  938 rmdir Mac/Modules/
  939 bzr revert Mac/Modules
  940 bzr diff | diffstat
  941 bzr conflicts
  942 mkdir Mac/Modules
  943 touch Mac/Modules/icgluemodule.c.THIS
  944 bzr revert Mac/Modules
  945 bzr revert Mac/Modules | less
  946 bzr revert Mac/Modules 2>&1 | less
  947 head --help
  948 bzr revert Mac/Modules 2>&1 | head -c 200 | less
  949 touch Mac/Modules/icgluemodule.c
  950 bzr revert Mac/Modules/ 2>&1 | less
  951 bzr help
  952 bzr help commands
  953 bzr gselftest
  954 bzr gselftest
Trying various things to get it to work again. No luck.

  955 bar add Mac/Modules
  956 bzr add Mac/Modules
  957 bzr diff Mac/Modules/
  958 bzr diff | diffstat
Success! It's 12 o'clock, and bzr knows where its children are!

  959 ls Mac/Modules/
  960 bzr conflicts
  961 bzr commit
  962 ls Mac/Modules/
  963 bzr remove Mac/Modules/*
  964 bzr remove Mac/Modules
  965 bzr diff | less
  966 bzr commit
Cleaned up, no conflict to deal with this time.

Hope this little adventure sheds some light on this bug.

Revision history for this message
pva (pva) wrote : Steps to reproduce: AssertionError: Could not find target parent in wt in wt4 _process_entry

Steps to reproduce similar problem:

peter@camobap ~/test $ mkdir -p dir/subdir
peter@camobap ~/test $ touch dir/subdir/file
peter@camobap ~/test $ bzr init && bzr add * && bzr commit -m I
added dir
added dir/subdir
added dir/subdir/file
Committing to: /home/peter/test/
added dir
added dir/subdir
added dir/subdir/file
Committed revision 1.
peter@camobap ~/test $ rm -r dir/
peter@camobap ~/test $ bzr rm dir/subdir
dir/subdir does not exist.
peter@camobap ~/test $ bzr rm dir
bzr: ERROR: exceptions.AssertionError: Could not find target parent in wt: dir/subdir
parent of: (('dir/subdir', 'file', 'file-20080606072830-px6o7dv2ghuoq404-3'), [('f', '', 0L, 0, 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'), ('f', 'da39a3ee5e6b4b0d3255bfef95601890afd80709', 0L, 0, '<email address hidden>')])

Traceback (most recent call last):
  File "/usr/lib/python2.5/site-packages/bzrlib/commands.py", line 846, in run_bzr_catch_errors
    return run_bzr(argv)
  File "/usr/lib/python2.5/site-packages/bzrlib/commands.py", line 797, in run_bzr
    ret = run(*run_argv)
  File "/usr/lib/python2.5/site-packages/bzrlib/commands.py", line 499, in run_argv_aliases
    return self.run(**all_cmd_args)
  File "/usr/lib/python2.5/site-packages/bzrlib/builtins.py", line 1176, in run
    force=file_deletion_strategy=='force')
  File "/usr/lib/python2.5/site-packages/bzrlib/mutabletree.py", line 52, in tree_write_locked
    return unbound(self, *args, **kwargs)
  File "/usr/lib/python2.5/site-packages/bzrlib/workingtree.py", line 1862, in remove
    want_unversioned=True, specific_files=files):
  File "/usr/lib/python2.5/site-packages/bzrlib/workingtree_4.py", line 2384, in iter_changes
    result = _process_entry(current_entry, current_path_info)
  File "/usr/lib/python2.5/site-packages/bzrlib/workingtree_4.py", line 2089, in _process_entry
    % (new_dirname, entry))
AssertionError: Could not find target parent in wt: dir/subdir
parent of: (('dir/subdir', 'file', 'file-20080606072830-px6o7dv2ghuoq404-3'), [('f', '', 0L, 0, 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'), ('f', 'da39a3ee5e6b4b0d3255bfef95601890afd80709', 0L, 0, '<email address hidden>')])

bzr 1.5 on python 2.5.2 (linux2)
arguments: ['/usr/bin/bzr', 'rm', 'dir']
encoding: 'UTF-8', fsenc: 'UTF-8', lang: 'ru_RU.UTF-8'
plugins:
  launchpad /usr/lib/python2.5/site-packages/bzrlib/plugins/launchpad [unknown]
*** Bazaar has encountered an internal error.
    Please report a bug at https://bugs.launchpad.net/bzr/+filebug
    including this traceback, and a description of what you
    were doing when the error occurred.

And please, could you tell me how to revert from broken state? I have local repository which is now in such state and I really do not want to loose changes...

Revision history for this message
Kai Webber (kai11) wrote : Re: AssertionError: Could not find target parent in wt in wt4 _process_entry

I manually removed directory like Adam Olsen described and now getting same crash on almost all commands.
Even restoring this directory back from other copy does not aid.

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

The workaround is to 'mkdir directory; bzr add directory; bzr status; bzr rm directory'. At least, that seemed to work for someone else.

Revision history for this message
James Westby (james-w) wrote :

Hi,

Hint from Rob via me:

It appears that something is deleting the entry without removing the children.

James

description: updated
description: updated
Changed in bzr:
assignee: nobody → lifeless
status: Confirmed → Fix Committed
Changed in bzr:
status: Fix Committed → 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.