comparison tests/fixtures/renames.sh @ 1233:0d0132cba155

editor: fix edge case with in memory file-store size limit There are a few cases where we will set a single file into to the editor's FileStore object more than once. Notably, for copied and then modified files, we will set it at least twice. Three times if editing fails (which it can for symlinks). If we pass the in-memory storage limit in between the first (or second if editing fails) time we set the file and the last time we set the file, we will write the data to the in memory store the first time and the file store the last time. We didn't remove it form the in-memory store though, and we always prefer reading from the in-memory store. This means we can sometimes end up with the wrong version of a file. This is fairly unlikely to happen in normal use since you need to hit the memory limit between two writes to the store for the same file. We only write a file multiple times if a) the file (and not one of it's parent directories) is copied and then modified or b) editing fails. From what I can tell, it's only common for editing to fail for symlinks, and they ten to be relatively small data that is unlikely to push over the limit. Finally, the default limit is 100MB which I would expect to be most often either well over (source code) or well under (binaries or automated changes) the size of the changes files in a single commit. The easiest way to reproduce this is to set the in-memory cache size to 0 and then commit a copied and modified symlink. The empty-string version from the failed editing will be the one that persists. I happened to stumble upon this while trying (and failing) to test a bug-fix for a related bug with identical symptoms (empty simlink). I have seen this in the wild, once, but couldn't reproduce it at the time. The repo in question is quite large and quite active, so I am quite confident in my estimation that this is a real, but very rare, problem. The test changes attached to this was mneant to test a related bug, but turned out not to actually cover the bug in question. They did trigger this bug though, and are worthwhile to test, so I kept them.
author David Schleimer <dschleimer@fb.com>
date Mon, 07 Apr 2014 17:51:59 -0700
parents c2a84d436202
children
comparison
equal deleted inserted replaced
1232:ba8485b9fee0 1233:0d0132cba155
1 #!/bin/sh 1 #!/bin/sh
2 # 2 #
3 # Generate renames.svndump 3 # Generate renames.svndump
4 # 4 #
5
6 set -e
7
8 rm -rf temp
5 9
6 mkdir temp 10 mkdir temp
7 cd temp 11 cd temp
8 12
9 mkdir project-orig 13 mkdir project-orig
19 svn co $svnurl project 23 svn co $svnurl project
20 cd project/trunk 24 cd project/trunk
21 # Entries for regular tests 25 # Entries for regular tests
22 echo a > a 26 echo a > a
23 echo b > b 27 echo b > b
28 ln -s a linka
29 ln -s b linkb
24 mkdir -p da/db 30 mkdir -p da/db
25 echo c > da/daf 31 echo c > da/daf
32 ln -s daf da/dalink
26 echo d > da/db/dbf 33 echo d > da/db/dbf
34 ln -s ../daf da/db/dblink
27 # Entries to test delete + copy 35 # Entries to test delete + copy
28 echo deleted > deletedfile 36 echo deleted > deletedfile
37 ln -s b deletedlink
29 mkdir deleteddir 38 mkdir deleteddir
30 echo deleteddir > deleteddir/f 39 echo deleteddir > deleteddir/f
40 ln -s f deleteddir/link
31 # Entries to test copy before change 41 # Entries to test copy before change
32 echo changed > changed 42 echo changed > changed
43 ln -s changed changedlink
33 mkdir changeddir 44 mkdir changeddir
34 echo changed2 > changeddir/f 45 echo changed2 > changeddir/f
46 ln -s f changeddir/link
35 # Entries unchanged in the rest of history 47 # Entries unchanged in the rest of history
36 echo unchanged > unchanged 48 echo unchanged > unchanged
49 ln -s unchanged unchangedlink
37 mkdir unchangeddir 50 mkdir unchangeddir
38 echo unchanged2 > unchangeddir/f 51 echo unchanged2 > unchangeddir/f
52 ln -s f unchangeddir/link
39 # One of the files will be changed afterwards, to test 53 # One of the files will be changed afterwards, to test
40 # group copies detection 54 # group copies detection
41 mkdir groupdir 55 mkdir groupdir
42 echo a > groupdir/a 56 echo a > groupdir/a
43 echo b > groupdir/b 57 echo b > groupdir/b
44 svn add a b da deletedfile deleteddir changed changeddir unchanged unchangeddir groupdir 58 ln -s a groupdir/linka
45 svn ci -m "add a and b" 59 ln -s b groupdir/linkb
60 svn add a b linka linkb da deleted* changed* unchanged* groupdir
61 svn ci -m "add everything"
46 # Remove files to be copied later 62 # Remove files to be copied later
47 svn rm deletedfile 63 svn rm deletedfile
48 svn rm deleteddir 64 svn rm deleteddir
65 svn rm deletedlink
49 # Update files to be copied before this change 66 # Update files to be copied before this change
50 echo changed >> changed 67 echo changed >> changed
51 echo changed2 >> changeddir/f 68 echo changed2 >> changeddir/f
69 ln -sfn changeddir/f changedlink
70 ln -sfn ../changed changeddir/link
52 # Update one of the groupdir files 71 # Update one of the groupdir files
53 echo a >> groupdir/a 72 echo a >> groupdir/a
73 ln -sfn ../a groupdir/linka
54 svn ci -m "delete files and dirs" 74 svn ci -m "delete files and dirs"
55 cd ../branches 75 cd ../branches
56 svn cp ../trunk branch1 76 svn cp ../trunk branch1
57 svn ci -m "create branch1" 77 svn ci -m "create branch1"
58 cd branch1 78 cd branch1
59 echo c > c 79 echo c > c
60 svn add c 80 ln -s c linkc
61 svn ci -m "add c" 81 svn add c linkc
82 svn ci -m "add c and linkc"
62 cd ../../trunk 83 cd ../../trunk
63 # Regular copy and rename 84 # Regular copy and rename
64 svn cp a a1 85 svn cp a a1
86 svn cp linka linka1
65 svn mv a a2 87 svn mv a a2
88 svn mv linka linka2
66 # Copy and update of source and dest 89 # Copy and update of source and dest
67 svn cp b b1 90 svn cp b b1
91 svn cp linkb linkb1
68 echo b >> b 92 echo b >> b
69 echo c >> b1 93 echo c >> b1
94 ln -sfn bb linkb
95 ln -sfn bc linkb1
70 # Directory copy and renaming 96 # Directory copy and renaming
71 svn cp da da1 97 svn cp da da1
72 svn mv da da2 98 svn mv da da2
73 # Test one copy operation in branch 99 # Test one copy operation in branch
74 cd ../branches/branch1 100 cd ../branches/branch1
75 svn cp c c1 101 svn cp c c1
102 svn cp linkc linkc1
76 echo c >> c1 103 echo c >> c1
104 ln -sfn cc linkc1
77 cd ../.. 105 cd ../..
78 svn ci -m "rename and copy a, b and da" 106 svn ci -m "rename and copy a, b, c and da, plus their links"
79 cd trunk 107 cd trunk
80 # Copy across branch 108 # Copy across branch
81 svn cp ../branches/branch1/c c 109 svn cp ../branches/branch1/c c
82 svn ci -m "copy b from branch1" 110 svn cp ../branches/branch1/linkc linkc
111 svn ci -m "copy c from branch1"
83 # Copy deleted stuff from the past 112 # Copy deleted stuff from the past
84 svn cp $svnurl/trunk/deletedfile@2 deletedfile 113 svn cp $svnurl/trunk/deletedfile@2 deletedfile
85 svn cp $svnurl/trunk/deleteddir@2 deleteddir 114 svn cp $svnurl/trunk/deleteddir@2 deleteddir
115 svn cp $svnurl/trunk/deletedlink@2 deletedlink
86 svn ci -m "copy stuff from the past" 116 svn ci -m "copy stuff from the past"
87 # Copy data from the past before it was changed 117 # Copy data from the past before it was changed
88 svn cp $svnurl/trunk/changed@2 changed2 118 svn cp $svnurl/trunk/changed@2 changed2
89 svn cp $svnurl/trunk/changeddir@2 changeddir2 119 svn cp $svnurl/trunk/changeddir@2 changeddir2
120 svn cp $svnurl/trunk/changedlink@2 changedlink2
90 # Harder, copy from the past before change and change it again 121 # Harder, copy from the past before change and change it again
91 # This confused the stupid diff path 122 # This confused the stupid diff path
92 svn cp $svnurl/trunk/changed@2 changed3 123 svn cp $svnurl/trunk/changed@2 changed3
124 svn cp $svnurl/trunk/changedlink@2 changedlink3
93 echo changed3 >> changed3 125 echo changed3 >> changed3
126 ln -sfn changed3 changedlink3
94 svn ci -m "copy stuff from the past before change" 127 svn ci -m "copy stuff from the past before change"
95 # Copy unchanged stuff from the past. Since no changed occured in these files 128 # Copy unchanged stuff from the past. Since no changed occured in these files
96 # between the source and parent revision, we record them as copy from parent 129 # between the source and parent revision, we record them as copy from parent
97 # instead of source rev. 130 # instead of source rev.
98 svn cp $svnurl/trunk/unchanged@2 unchanged2 131 svn cp $svnurl/trunk/unchanged@2 unchanged2
99 svn cp $svnurl/trunk/unchangeddir@2 unchangeddir2 132 svn cp $svnurl/trunk/unchangeddir@2 unchangeddir2
133 svn cp $svnurl/trunk/unchangedlink@2 unchangedlink2
100 svn ci -m "copy unchanged stuff from the past" 134 svn ci -m "copy unchanged stuff from the past"
101 # Copy groupdir, unfortunately one file was changed after r2 so the 135 # Copy groupdir, unfortunately one file was changed after r2 so the
102 # copy should not be recorded at all 136 # copy should not be recorded at all
103 svn cp $svnurl/trunk/groupdir@2 groupdir2 137 svn cp $svnurl/trunk/groupdir@2 groupdir2
104 svn ci -m "copy groupdir from the past" 138 svn ci -m "copy groupdir from the past"