Ticket #1512: fix-zero-length-reads.darcspatch

File fix-zero-length-reads.darcspatch, 9.8 KB (added by kevan, at 2011-08-30T21:09:41Z)

fix zero-length reads; enable tests of zero-length reads

Line 
1Tue Aug 30 14:01:41 PDT 2011  Kevan Carstensen <kevan@isnotajoke.com>
2  * mutable/retrieve: handle the case where self._read_length is 0.
3 
4  Note that the downloader will still fetch a segment for a zero-length
5  read, which is wasteful. Fixing that isn't specifically required to fix
6  #1512, but it should probably be fixed before 1.9.
7
8New patches:
9
10[mutable/retrieve: handle the case where self._read_length is 0.
11Kevan Carstensen <kevan@isnotajoke.com>**20110830210141
12 Ignore-this: fceafbe485851ca53f2774e5a4fd8d30
13 
14 Note that the downloader will still fetch a segment for a zero-length
15 read, which is wasteful. Fixing that isn't specifically required to fix
16 #1512, but it should probably be fixed before 1.9.
17] {
18hunk ./src/allmydata/mutable/retrieve.py 407
19             self._start_segment = 0
20 
21 
22-        if self._read_length:
23+        # If self._read_length is None, then we want to read the whole
24+        # file. Otherwise, we want to read only part of the file, and
25+        # need to figure out where to stop reading.
26+        if self._read_length is not None:
27             # our end segment is the last segment containing part of the
28             # segment that we were asked to read.
29             self.log("got read length %d" % self._read_length)
30hunk ./src/allmydata/mutable/retrieve.py 414
31-            end_data = self._offset + self._read_length
32+            if self._read_length != 0:
33+                end_data = self._offset + self._read_length
34 
35hunk ./src/allmydata/mutable/retrieve.py 417
36-            # We don't actually need to read the byte at end_data, but
37-            # the one before it.
38-            end = (end_data - 1) // self._segment_size
39+                # We don't actually need to read the byte at end_data,
40+                # but the one before it.
41+                end = (end_data - 1) // self._segment_size
42 
43hunk ./src/allmydata/mutable/retrieve.py 421
44-            assert end < self._num_segments
45-            self._last_segment = end
46+                assert end < self._num_segments
47+                self._last_segment = end
48+            else:
49+                self._last_segment = self._start_segment
50             self.log("got end segment: %d" % self._last_segment)
51         else:
52             self._last_segment = self._num_segments - 1
53hunk ./src/allmydata/test/test_mutable.py 3308
54     def test_partial_read_ending_one_byte_after_segment_boundary(self):
55         return self._test_partial_read(mathutil.next_multiple(128 * 1024, 3)-50, 51)
56 
57+    # XXX factor these into a single upload after they pass
58     def test_partial_read_zero_length_at_start(self):
59         return self._test_partial_read(0, 0)
60 
61hunk ./src/allmydata/test/test_mutable.py 3318
62     def test_partial_read_zero_length_at_segment_boundary(self):
63         return self._test_partial_read(mathutil.next_multiple(128 * 1024, 3), 0)
64 
65-    # XXX factor these into a single upload after they pass
66-    _broken = "zero-length reads of mutable files don't work"
67-    test_partial_read_zero_length_at_start.todo = _broken
68-    test_partial_read_zero_length_in_middle.todo = _broken
69-    test_partial_read_zero_length_at_segment_boundary.todo = _broken
70 
71     def _test_read_and_download(self, node, expected):
72         d = node.get_best_readable_version()
73}
74
75Context:
76
77[NEWS: added summary of all changes since 1.8.2. Needs editing.
78Brian Warner <warner@lothar.com>**20110830163205
79 Ignore-this: 273899b37a899fc6919b74572454b8b2
80] 
81[test_mutable.Update: only upload the files needed for each test. refs #1500
82Brian Warner <warner@lothar.com>**20110829072717
83 Ignore-this: 4d2ab4c7523af9054af7ecca9c3d9dc7
84 
85 This first step shaves 15% off the runtime: from 139s to 119s on my laptop.
86 It also fixes a couple of places where a Deferred was being dropped, which
87 would cause two tests to run in parallel and also confuse error reporting.
88] 
89[Let Uploader retain History instead of passing it into upload(). Fixes #1079.
90Brian Warner <warner@lothar.com>**20110829063246
91 Ignore-this: 3902c58ec12bd4b2d876806248e19f17
92 
93 This consistently records all immutable uploads in the Recent Uploads And
94 Downloads page, regardless of code path. Previously, certain webapi upload
95 operations (like PUT /uri/$DIRCAP/newchildname) failed to pass the History
96 object and were left out.
97] 
98[Fix mutable publish/retrieve timing status displays. Fixes #1505.
99Brian Warner <warner@lothar.com>**20110828232221
100 Ignore-this: 4080ce065cf481b2180fd711c9772dd6
101 
102 publish:
103 * encrypt and encode times are cumulative, not just current-segment
104 
105 retrieve:
106 * same for decrypt and decode times
107 * update "current status" to include segment number
108 * set status to Finished/Failed when download is complete
109 * set progress to 1.0 when complete
110 
111 More improvements to consider:
112 * progress is currently 0% or 100%: should calculate how many segments are
113   involved (remembering retrieve can be less than the whole file) and set it
114   to a fraction
115 * "fetch" time is fuzzy: what we want is to know how much of the delay is not
116   our own fault, but since we do decode/decrypt work while waiting for more
117   shares, it's not straightforward
118] 
119[Teach 'tahoe debug catalog-shares about MDMF. Closes #1507.
120Brian Warner <warner@lothar.com>**20110828080931
121 Ignore-this: 56ef2951db1a648353d7daac6a04c7d1
122] 
123[debug.py: remove some dead comments
124Brian Warner <warner@lothar.com>**20110828074556
125 Ignore-this: 40e74040dd4d14fd2f4e4baaae506b31
126] 
127[hush pyflakes
128Brian Warner <warner@lothar.com>**20110828074254
129 Ignore-this: bef9d537a969fa82fe4decc4ba2acb09
130] 
131[MutableFileNode.set_downloader_hints: never depend upon order of dict.values()
132Brian Warner <warner@lothar.com>**20110828074103
133 Ignore-this: caaf1aa518dbdde4d797b7f335230faa
134 
135 The old code was calculating the "extension parameters" (a list) from the
136 downloader hints (a dictionary) with hints.values(), which is not stable, and
137 would result in corrupted filecaps (with the 'k' and 'segsize' hints
138 occasionally swapped). The new code always uses [k,segsize].
139] 
140[layout.py: fix MDMF share layout documentation
141Brian Warner <warner@lothar.com>**20110828073921
142 Ignore-this: 3f13366fed75b5e31b51ae895450a225
143] 
144[teach 'tahoe debug dump-share' about MDMF and offsets. refs #1507
145Brian Warner <warner@lothar.com>**20110828073834
146 Ignore-this: 3a9d2ef9c47a72bf1506ba41199a1dea
147] 
148[test_mutable.Version.test_debug: use splitlines() to fix buildslaves
149Brian Warner <warner@lothar.com>**20110828064728
150 Ignore-this: c7f6245426fc80b9d1ae901d5218246a
151 
152 Any slave running in a directory with spaces in the name was miscounting
153 shares, causing the test to fail.
154] 
155[test_mutable.Version: exercise 'tahoe debug find-shares' on MDMF. refs #1507
156Brian Warner <warner@lothar.com>**20110828005542
157 Ignore-this: cb20bea1c28bfa50a72317d70e109672
158 
159 Also changes NoNetworkGrid to put shares in storage/shares/ .
160] 
161[test_mutable.py: oops, missed a .todo
162Brian Warner <warner@lothar.com>**20110828002118
163 Ignore-this: fda09ae86481352b7a627c278d2a3940
164] 
165[test_mutable: merge davidsarah's patch with my Version refactorings
166warner@lothar.com**20110827235707
167 Ignore-this: b5aaf481c90d99e33827273b5d118fd0
168] 
169[Make the immutable/read-only constraint checking for MDMF URIs identical to that for SSK URIs. refs #393
170david-sarah@jacaranda.org**20110823012720
171 Ignore-this: e1f59d7ff2007c81dbef2aeb14abd721
172] 
173[Additional tests for MDMF URIs and for zero-length files. refs #393
174david-sarah@jacaranda.org**20110823011532
175 Ignore-this: a7cc0c09d1d2d72413f9cd227c47a9d5
176] 
177[Additional tests for zero-length partial reads and updates to mutable versions. refs #393
178david-sarah@jacaranda.org**20110822014111
179 Ignore-this: 5fc6f4d06e11910124e4a277ec8a43ea
180] 
181[test_mutable.Version: factor out some expensive uploads, save 25% runtime
182Brian Warner <warner@lothar.com>**20110827232737
183 Ignore-this: ea37383eb85ea0894b254fe4dfb45544
184] 
185[SDMF: update filenode with correct k/N after Retrieve. Fixes #1510.
186Brian Warner <warner@lothar.com>**20110827225031
187 Ignore-this: b50ae6e1045818c400079f118b4ef48
188 
189 Without this, we get a regression when modifying a mutable file that was
190 created with more shares (larger N) than our current tahoe.cfg . The
191 modification attempt creates new versions of the (0,1,..,newN-1) shares, but
192 leaves the old versions of the (newN,..,oldN-1) shares alone (and throws a
193 assertion error in SDMFSlotWriteProxy.finish_publishing in the process).
194 
195 The mixed versions that result (some shares with e.g. N=10, some with N=20,
196 such that both versions are recoverable) cause problems for the Publish code,
197 even before MDMF landed. Might be related to refs #1390 and refs #1042.
198] 
199[layout.py: annotate assertion to figure out 'tahoe backup' failure
200Brian Warner <warner@lothar.com>**20110827195253
201 Ignore-this: 9b92b954e3ed0d0f80154fff1ff674e5
202] 
203[Add 'tahoe debug dump-cap' support for MDMF, DIR2-CHK, DIR2-MDMF. refs #1507.
204Brian Warner <warner@lothar.com>**20110827195048
205 Ignore-this: 61c6af5e33fc88e0251e697a50addb2c
206 
207 This also adds tests for all those cases, and fixes an omission in uri.py
208 that broke parsing of DIR2-MDMF-Verifier and DIR2-CHK-Verifier.
209] 
210[MDMF: more writable/writeable consistentifications
211warner@lothar.com**20110827190602
212 Ignore-this: 22492a9e20c1819ddb12091062888b55
213] 
214[MDMF: s/Writable/Writeable/g, for consistency with existing SDMF code
215warner@lothar.com**20110827183357
216 Ignore-this: 9dd312acedbdb2fc2f7bef0d0fb17c0b
217] 
218[setup.cfg: remove no-longer-supported test_mac_diskimage alias. refs #1479
219david-sarah@jacaranda.org**20110826230345
220 Ignore-this: 40e908b8937322a290fb8012bfcad02a
221] 
222[test_mutable.Update: increase timeout from 120s to 400s, slaves are failing
223Brian Warner <warner@lothar.com>**20110825230140
224 Ignore-this: 101b1924a30cdbda9b2e419e95ca15ec
225] 
226[tests: fix check_memory test
227zooko@zooko.com**20110825201116
228 Ignore-this: 4d66299fa8cb61d2ca04b3f45344d835
229 fixes #1503
230] 
231[TAG allmydata-tahoe-1.9.0a1
232warner@lothar.com**20110825161122
233 Ignore-this: 3cbf49f00dbda58189f893c427f65605
234] 
235Patch bundle hash:
236e0d3445f7303246cf5a42da8cf674a38bb13da11