#943 new defect

"tahoe mv" deleted my files?

Reported by: zooko Owned by: daira
Priority: critical Milestone: soon
Component: code-frontend-cli Version: 1.6.0
Keywords: tahoe-mv usability preservation sftp ftpd Cc:
Launchpad Bug:

Description (last modified by daira)

I had a bunch of files in a directory and I wanted to mv them into a subdirectory. So first I ran "tahoe ls" to make sure I could get the names of the files:

$ time ~/playground/tahoe-lafs/bin/tahoe ls --dir-cap=URI:DIR2:zssplcanct54waahwjjngjyhke:vvdpvxybwc6x7az5i64heqdnql2mdi6fspvxtje4iwzkcvvwukpq  tahoe:
01 - Balrog Boogie.mp3
02 - Heroines.mp3
03 - Poetic Pitbull Revolutions.mp3
04 - Rag Doll Physics.mp3
05 - D'angelo.mp3
06 - Velvet Embracer.mp3
07 - Gunpowder Chant.mp3
08 - Infralove.mp3
09 - Wedding March for a Bullet.mp3
10 - Qualms of Conscience.mp3
11 - Zodiac Virtues.mp3
12 - Porcelain Judas.mp3
13 - Pink Noise Waltz.mp3
Diablo_Swing_Orchestra-The_Butcher's_Ballroom
Gaetano Verdi
License.txt
Readme - www.jamendo.com .txt
[cover] Diablo Swing Orchestra - The Butcher's Ballroom.jpg
on_ootles

real    0m0.926s
user    0m0.490s
sys     0m0.219s

Then I wrote this bash script that runs "tahoe mv tahoe:$FILENAME tahoe:new_subdir/":

$ for F in ` ~/playground/tahoe-lafs/bin/tahoe ls --dir-cap=URI:DIR2:zssplcanct54waahwjjngjyhke:vvdpvxybwc6x7az5i64heqdnql2mdi6fspvxtje4iwzkcvvwukpq  tahoe:` ; do echo $F; time ~/playground/tahoe-lafs/bin/tahoe mv --dir-cap=URI:DIR2:zssplcanct54waahwjjngjyhke:vvdpvxybwc6x7az5i64heqdnql2mdi6fspvxtje4iwzkcvvwukpq  "tahoe:${F}" tahoe:Diablo_Swing_Orchestra-The_Butcher\'s_Ballroom/ ; done

01 - Balrog Boogie.mp3
OK

real    0m3.862s
user    0m0.492s
sys     0m0.218s
02 - Heroines.mp3
OK

real    0m2.803s
user    0m0.497s
sys     0m0.215s
03 - Poetic Pitbull Revolutions.mp3
OK

real    0m7.097s
user    0m0.498s
sys     0m0.223s
04 - Rag Doll Physics.mp3
OK

real    0m2.770s
user    0m0.492s
sys     0m0.217s
05 - D'angelo.mp3
OK

real    0m3.383s
user    0m0.501s
sys     0m0.223s
06 - Velvet Embracer.mp3
OK

real    0m2.815s
user    0m0.497s
sys     0m0.217s
07 - Gunpowder Chant.mp3
OK

real    0m3.557s
user    0m0.506s
sys     0m0.232s
08 - Infralove.mp3
OK

real    0m2.846s
user    0m0.505s
sys     0m0.227s
09 - Wedding March for a Bullet.mp3
OK

real    0m3.492s
user    0m0.493s
sys     0m0.219s
10 - Qualms of Conscience.mp3
OK

real    0m3.635s
user    0m0.490s
sys     0m0.217s
11 - Zodiac Virtues.mp3
OK

real    0m2.774s
user    0m0.494s
sys     0m0.220s
12 - Porcelain Judas.mp3
OK

real    0m3.298s
user    0m0.490s
sys     0m0.217s
13 - Pink Noise Waltz.mp3
OK

real    0m3.997s
user    0m0.497s
sys     0m0.223s
Diablo_Swing_Orchestra-The_Butcher's_Ballroom
OK

real    0m2.859s
user    0m0.507s
sys     0m0.226s
Gaetano Verdi
OK

real    0m4.548s
user    0m0.502s
sys     0m0.226s
License.txt
OK

real    0m3.194s
user    0m0.507s
sys     0m0.227s
Readme - www.jamendo.com .txt
OK

real    0m2.772s
user    0m0.500s
sys     0m0.226s
[cover] Diablo Swing Orchestra - The Butcher's Ballroom.jpg
OK

real    0m3.347s
user    0m0.503s
sys     0m0.221s
on_ootles
OK

real    0m3.750s
user    0m0.506s
sys     0m0.227s

All mv's reported OK. So far so good.

Then I went to play the music files from their new locations and... What the heck?? All the .mp3 files are gone, but the other files are still there??

$ time ~/playground/tahoe-lafs/bin/tahoe ls --dir-cap=URI:DIR2:zssplcanct54waahwjjngjyhke:vvdpvxybwc6x7az5i64heqdnql2mdi6fspvxtje4iwzkcvvwukpq  tahoe:Diablo_Swing_Orchestra-The_Butcher\'s_Ballroom

Gaetano Verdi
License.txt
Readme - www.jamendo.com .txt
[cover] Diablo Swing Orchestra - The Butcher's Ballroom.jpg
on_ootles

real    0m1.054s
user    0m0.475s
sys     0m0.211s

Change History (27)

comment:1 follow-up: Changed at 2010-02-09T02:36:23Z by davidsarah

I suspect that you moved the directory Diablo_Swing_Orchestra-The_Butcher's_Ballroom into itself. That is what the bash script literally says to do -- the script would have first moved all of the .mp3 files (which happen to be listed before Diablo_Swing_Orchestra-The_Butcher's_Ballroom) into that directory, and then do:

time ~/playground/tahoe-lafs/bin/tahoe mv --dir-
 cap=URI:DIR2:zssplcanct54waahwjjngjyhke:vvdpvxybwc6x7az5i64heqdnql2mdi6fspvxtje4iwzkcvvwukpq "tahoe:Diablo_Swing_Orchestra-The_Butcher's_Ballroom" tahoe:Diablo_Swing_Orchestra-The_Butcher\'s_Ballroom/

which causes said directory to disappear up its own... erm, I mean, become a child of itself.

I don't understand why the subsequent mvs printed OK. They didn't work, as I wouldn't expect since Diablo_Swing_Orchestra-The_Butcher's_Ballroom wouldn't be a child of URI:DIR2:zssplcanct54waahwjjngjyhke:vvdpvxybwc6x7az5i64heqdnql2mdi6fspvxtje4iwzkcvvwukpq at that point. It seems like a bug that they printed OK, independent of whether the preceding "move a directory into itself" command should have been allowed.

If you still have a direct cap to the Diablo_Swing_Orchestra-The_Butcher's_Ballroom directory, then it should still exist, with the .mp3 files in it.

A directory being a child of itself isn't a problem per se, in a Tahoe filesystem. OTOH, Unix mv will not allow moving a directory into itself. On cygwin:

$ mv foo foo/
mv: cannot move `foo' to a subdirectory of itself, `foo/foo'

However tahoe mv works by doing a PUT operation to create the destination link, and then if that succeeded, doing a DELETE on the source link. It would be possible to check that the source object is not the same as the parent of the destination link, but that only catches some cases that are prevented by Univ mv: you would still be able to move a directory into an indirect descendant, and it isn't clear how to prevent that.

comment:2 in reply to: ↑ 1 Changed at 2010-02-09T02:37:43Z by davidsarah

Replying to davidsarah:

I don't understand why the subsequent mvs printed OK. They didn't work, as I wouldn't expect since Diablo_Swing_Orchestra-The_Butcher's_Ballroom wouldn't be a child of URI:DIR2:zssplcanct54waahwjjngjyhke:vvdpvxybwc6x7az5i64heqdnql2mdi6fspvxtje4iwzkcvvwukpq at that point.

I meant, they didn't work, as I would expect.

comment:3 Changed at 2010-02-15T20:31:25Z by davidsarah

  • Milestone changed from undecided to 1.6.1

comment:4 Changed at 2010-02-16T05:56:56Z by davidsarah

Normally, tahoe mv would not result in any data loss because the issuer of the command must have the cap that starts the destination path. In the case described in this bug, however, we delete one of the links in that path, because it is the same as the source link.

Therefore, the potential data loss can be fixed by checking whether any of the destination links are the same as the link that is to be moved. This should match the expectations of users accustomed to Unix mv or moving files in a Windows filesystem, which would fail in the same situation. Note that we are not enforcing that it is impossible to create loops using tahoe mv -- that's not necessary to fix this bug.

The link to be moved must be from a mutable directory, therefore it has an SI. So, the definition of "same as" for links can be "same parent directory SI, and same child name" (comparing child names as Unicode strings without normalization).

The later mvs reporting OK is a separate issue that we haven't investigated yet.

[edit: I think when this comment was written, names were not normalized. Now they are, so the comparison should be with NFC normalization.]

Last edited at 2012-05-10T01:02:54Z by davidsarah (previous) (diff)

comment:5 Changed at 2010-02-22T05:14:34Z by zooko

  • Milestone changed from 1.6.1 to 1.7.0

We're not going to finish this in time for v1.6.1, but hopefully for v1.7.0!

comment:6 Changed at 2010-03-02T01:25:52Z by davidsarah

  • Owner set to davidsarah
  • Priority changed from major to critical
  • Status changed from new to assigned

comment:7 follow-up: Changed at 2010-03-07T21:31:40Z by davidsarah

  • Keywords sftp added

This also affects the rename operation in SFTP. The approach of comment:4 can also be used there, although it's a different code path.

comment:8 in reply to: ↑ 7 Changed at 2010-03-07T21:42:07Z by davidsarah

  • Keywords ftpd added

Replying to davidsarah:

This also affects the rename operation in SFTP.

... and FTP, in theory, although the FTP RNFR/RNTO commands are somewhat obscure.

comment:9 Changed at 2010-05-16T23:40:25Z by zooko

  • Milestone changed from 1.7.0 to eventually

comment:10 Changed at 2010-05-17T02:14:40Z by davidsarah

  • Milestone changed from eventually to soon

comment:11 Changed at 2010-06-10T15:48:38Z by davidsarah

  • Milestone changed from soon to 1.8.0
  • Version changed from 1.6.0 to 1.6.1

comment:12 Changed at 2010-06-10T15:49:57Z by davidsarah

  • Version changed from 1.6.1 to 1.6.0

Don't know why that last update changed the Version field.

comment:13 follow-up: Changed at 2010-06-10T16:23:24Z by davidsarah

http://tahoe-lafs.org/trac/tahoe-lafs/changeset/4435#file15 fixed one case in which it was possible for tahoe mv to print "OK" after an error (when the source file cannot be removed after the destination file has been successfully added). However, that doesn't appear to be the case involved here, because it would have had to print an error message to stderr first.

Note that tahoe mv uses a PUT then a DELETE of the original file, not a POST with ?t=rename. It would have to be changed to do the latter (now called ?t=relink), as well as changing ?t=relink to do the path check, in order for the approach of comment:4 to work.

Last edited at 2015-05-11T13:23:21Z by daira (previous) (diff)

comment:14 Changed at 2010-06-12T20:54:33Z by davidsarah

  • Milestone changed from 1.8.0 to 1.7.1

comment:15 Changed at 2010-06-28T22:46:12Z by zooko

I just (accidentally) reproduced this problem in Tahoe-LAFS v1.7.0:

for F in `tahoe ls --node-url=http://127.0.0.1:3456 $RODIRCAP
`; do 
tahoe mv --node-url=http://127.0.0.1:3456 "$RWDIRCAP/${F}" "$RWDIRCAP/papers/;
done

Since "papers" was one of the children of the directory, this resulted in:

tahoe mv --node-url=http://127.0.0.1:3456 "$RWDIRCAP/papers" "$RWDIRCAP/papers/;

Which first linked papers to be a child of papers and then unlinked it from being a child of $RWDIRCAP. Whoops!

(I saw that this was about to happen as the for loop was progressing so I switched to my web browser that was viewing $RWDIRCAP and clicked on the "papers" child that was still listed there, thus retaining a link to papers.)

comment:16 Changed at 2010-07-17T03:47:17Z by davidsarah

  • Milestone changed from 1.7.1 to 1.8β

comment:17 Changed at 2010-08-10T03:42:18Z by davidsarah

  • Milestone changed from 1.8β to 1.9.0

comment:18 in reply to: ↑ 13 Changed at 2010-11-10T01:46:36Z by davidsarah

Replying to davidsarah:

http://tahoe-lafs.org/trac/tahoe-lafs/changeset/4435#file15 fixed one case in which it was possible for tahoe mv to print "OK" after an error (when the source file cannot be removed after the destination file has been successfully added). However, that doesn't appear to be the case involved here, because it would have had to print an error message to stderr first.

In fact that changeset didn't properly fix that case; see #1255. It is not true that it would have had to print an error message to stderr first, so the possibility of this being the explanation for the "OK" output in this ticket should be reconsidered.

comment:19 Changed at 2011-08-02T15:55:19Z by davidsarah

  • Milestone changed from 1.9.0 to soon

comment:20 Changed at 2011-08-15T04:23:17Z by davidsarah

  • Milestone changed from soon to 1.10.0

comment:21 Changed at 2011-11-18T02:00:57Z by davidsarah

Reminder that #1579 will probably introduce another case where this can happen.

comment:22 Changed at 2012-05-10T01:07:31Z by davidsarah

See also ticket:1732#comment:2, which would add a web-API call that might be useful for implementing comment:4.

comment:23 Changed at 2015-05-11T13:24:15Z by daira

  • Description modified (diff)
  • Milestone changed from soon to 1.11.0
  • Owner changed from davidsarah to daira
  • Status changed from assigned to new

comment:24 Changed at 2016-03-22T05:02:52Z by warner

  • Milestone changed from 1.11.0 to 1.12.0

Milestone renamed

comment:25 Changed at 2016-06-28T18:20:37Z by warner

  • Milestone changed from 1.12.0 to 1.13.0

moving most tickets from 1.12 to 1.13 so we can release 1.12 with magic-folders

comment:26 Changed at 2020-06-30T14:45:13Z by exarkun

  • Milestone changed from 1.13.0 to 1.15.0

Moving open issues out of closed milestones.

comment:27 Changed at 2021-03-30T18:40:19Z by meejah

  • Milestone changed from 1.15.0 to soon

Ticket retargeted after milestone closed

Note: See TracTickets for help on using tickets.