Commit c45b4b9
authored
fix(meta-service): Remove transient
* refactor(meta-service): write test to expose a bug with expiration consistency
Tests timestamp-based expiration consistency across snapshot boundaries.
**Scenario:**
- Log-1 has timestamp T+180s, included in snapshot
- Log-2 has timestamp T+60s with expiration T+120s, not in snapshot
**Issue:** After restart, Log-2 uses current time instead of last-seen time (from Log-1)
for expiration checks, potentially causing state inconsistencies between nodes.
This bug raises in real world if:
- When meta-service restarts, there is one log(`A`) to re-apply that has
smaller `expire_at`(`t1`) than the biggest timestamp(`LogEntry.time_ms`)
in the snapshot,
- and all the log entries before `A` have smaller timestamp(`LogEntry.time_ms`) than `t1`.
* fix(meta-service): Remove transient `expire_cursor` to prevent state inconsistency
Fix potential state machine inconsistencies caused by the non-persisted
`expire_cursor` field. While inconsistencies were rare, the transient
state could cause meta-service nodes to have divergent views of the
expiration processing state.
Root cause:
The `expire_cursor` was maintained as transient state outside the
replicated state machine, making it possible for nodes to have different
cursor positions after restarts or network partitions.
Solution:
Remove the non-persisted `expire_cursor` entirely to ensure all state
machine operations are fully deterministic and consistently replicated
across all meta-service nodes.
This change eliminates the race condition and guarantees state machine
consistency regardless of node restart patterns or network conditions.expire_cursor to prevent state inconsistency (#18318)1 parent 820d63b commit c45b4b9
File tree
7 files changed
+158
-81
lines changed- src/meta
- raft-store/src
- applier
- sm_v003
- service/tests/it/meta_node
7 files changed
+158
-81
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
688 | 688 | | |
689 | 689 | | |
690 | 690 | | |
691 | | - | |
692 | | - | |
693 | 691 | | |
694 | 692 | | |
695 | 693 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | 49 | | |
58 | 50 | | |
59 | 51 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
17 | 18 | | |
18 | 19 | | |
19 | 20 | | |
| |||
137 | 138 | | |
138 | 139 | | |
139 | 140 | | |
140 | | - | |
141 | | - | |
142 | | - | |
143 | | - | |
144 | | - | |
145 | | - | |
146 | | - | |
147 | | - | |
148 | | - | |
149 | | - | |
150 | | - | |
151 | | - | |
152 | | - | |
153 | | - | |
154 | | - | |
155 | | - | |
156 | | - | |
157 | | - | |
158 | | - | |
159 | | - | |
160 | 141 | | |
161 | 142 | | |
162 | 143 | | |
| |||
221 | 202 | | |
222 | 203 | | |
223 | 204 | | |
224 | | - | |
| 205 | + | |
225 | 206 | | |
226 | 207 | | |
227 | 208 | | |
| |||
251 | 232 | | |
252 | 233 | | |
253 | 234 | | |
254 | | - | |
255 | | - | |
256 | 235 | | |
257 | 236 | | |
258 | 237 | | |
259 | 238 | | |
260 | 239 | | |
261 | 240 | | |
262 | 241 | | |
| 242 | + | |
263 | 243 | | |
264 | 244 | | |
265 | 245 | | |
| |||
270 | 250 | | |
271 | 251 | | |
272 | 252 | | |
273 | | - | |
274 | | - | |
275 | 253 | | |
| 254 | + | |
276 | 255 | | |
277 | 256 | | |
278 | 257 | | |
| |||
290 | 269 | | |
291 | 270 | | |
292 | 271 | | |
293 | | - | |
| 272 | + | |
294 | 273 | | |
295 | 274 | | |
296 | 275 | | |
| |||
299 | 278 | | |
300 | 279 | | |
301 | 280 | | |
| 281 | + | |
302 | 282 | | |
303 | 283 | | |
304 | 284 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | 53 | | |
68 | 54 | | |
69 | 55 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
73 | 73 | | |
74 | 74 | | |
75 | 75 | | |
76 | | - | |
| 76 | + | |
| 77 | + | |
77 | 78 | | |
78 | | - | |
| 79 | + | |
79 | 80 | | |
80 | | - | |
| 81 | + | |
81 | 82 | | |
82 | 83 | | |
83 | 84 | | |
| |||
177 | 178 | | |
178 | 179 | | |
179 | 180 | | |
180 | | - | |
181 | | - | |
182 | 181 | | |
183 | 182 | | |
184 | 183 | | |
185 | | - | |
186 | | - | |
187 | | - | |
188 | | - | |
189 | | - | |
190 | | - | |
| 184 | + | |
191 | 185 | | |
192 | | - | |
193 | | - | |
194 | | - | |
195 | | - | |
196 | | - | |
197 | | - | |
198 | | - | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
199 | 192 | | |
200 | 193 | | |
201 | 194 | | |
202 | 195 | | |
203 | | - | |
204 | | - | |
205 | | - | |
206 | | - | |
207 | | - | |
208 | | - | |
209 | | - | |
210 | | - | |
211 | | - | |
212 | | - | |
213 | | - | |
214 | | - | |
215 | | - | |
216 | 196 | | |
217 | 197 | | |
218 | 198 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
Lines changed: 140 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
0 commit comments