Commit dea2d97
committed
fix(audience): drop DiskStore._cachedCount, read file count from disk
Removes the cached on-disk file counter and the BumpCount delta
tracking that maintained it. Count() now calls Directory.GetFiles
each time.
Why
- File.Delete silently succeeds when the path is missing, so
TryDelete returned true regardless of whether a real file went
away. Two concurrent flushes that both called Delete on the same
paths each got true back and each called BumpCount(-1), drifting
the cached count negative.
- Shutdown's force-clear of _sendInFlight followed by an ungated
final SendBatchAsync gave the race a real opening (visible as
the StatusBar_QueueSizeIncrementsAfterTrack flake on Linux Unity 6,
where finalCount went past zero into "got -2").
- The cached counter was already documented as approximate ("Tests
that plant files outside the DiskStore API will drift this and
should assert on filesystem state, not Count()"), so callers
could not rely on it anyway.
Trade-off: Count() is now O(N) on the queue directory. The only
caller is ImmutableAudience.QueueSize, read from a 500 ms UI poll
and a couple of test assertions, so this is fine for any realistic
queue size and removes an entire class of drift.
TryDelete drops its bool return because nothing needs to know
whether a real file was removed once we are not counting deltas.1 parent 809e141 commit dea2d97
1 file changed
Lines changed: 21 additions & 29 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
9 | 8 | | |
10 | 9 | | |
11 | 10 | | |
| |||
15 | 14 | | |
16 | 15 | | |
17 | 16 | | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | 17 | | |
25 | 18 | | |
26 | 19 | | |
27 | 20 | | |
28 | | - | |
29 | 21 | | |
30 | 22 | | |
31 | 23 | | |
| |||
37 | 29 | | |
38 | 30 | | |
39 | 31 | | |
40 | | - | |
41 | 32 | | |
42 | 33 | | |
43 | 34 | | |
| |||
46 | 37 | | |
47 | 38 | | |
48 | 39 | | |
49 | | - | |
50 | 40 | | |
51 | | - | |
52 | | - | |
53 | 41 | | |
54 | 42 | | |
55 | 43 | | |
| |||
86 | 74 | | |
87 | 75 | | |
88 | 76 | | |
89 | | - | |
| 77 | + | |
90 | 78 | | |
91 | 79 | | |
92 | 80 | | |
| |||
101 | 89 | | |
102 | 90 | | |
103 | 91 | | |
104 | | - | |
| 92 | + | |
105 | 93 | | |
106 | 94 | | |
107 | | - | |
108 | | - | |
109 | | - | |
110 | | - | |
111 | | - | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
112 | 103 | | |
113 | | - | |
| 104 | + | |
114 | 105 | | |
115 | | - | |
116 | | - | |
117 | | - | |
118 | | - | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
119 | 110 | | |
| 111 | + | |
120 | 112 | | |
121 | 113 | | |
122 | 114 | | |
123 | 115 | | |
124 | 116 | | |
125 | 117 | | |
126 | 118 | | |
127 | | - | |
| 119 | + | |
128 | 120 | | |
129 | 121 | | |
130 | 122 | | |
| |||
145 | 137 | | |
146 | 138 | | |
147 | 139 | | |
148 | | - | |
| 140 | + | |
149 | 141 | | |
150 | 142 | | |
151 | 143 | | |
152 | 144 | | |
153 | 145 | | |
154 | | - | |
| 146 | + | |
155 | 147 | | |
156 | 148 | | |
157 | 149 | | |
| |||
195 | 187 | | |
196 | 188 | | |
197 | 189 | | |
198 | | - | |
| 190 | + | |
199 | 191 | | |
200 | 192 | | |
201 | 193 | | |
202 | | - | |
| 194 | + | |
203 | 195 | | |
204 | 196 | | |
205 | 197 | | |
| |||
0 commit comments