CARVIEW |
Select Language
HTTP/2 301
date: Tue, 29 Jul 2025 17:19:48 GMT
content-type: text/html; charset=utf-8
content-length: 0
vary: X-PJAX, X-PJAX-Container, Turbo-Visit, Turbo-Frame, X-Requested-With,Accept-Encoding, Accept, X-Requested-With
location: https://github.com/databendlabs/openraft/commit/eed681d57950fc58b6ca71a45814b8f6d2bb1223
cache-control: no-cache
strict-transport-security: max-age=31536000; includeSubdomains; preload
x-frame-options: deny
x-content-type-options: nosniff
x-xss-protection: 0
referrer-policy: origin-when-cross-origin, strict-origin-when-cross-origin
content-security-policy: default-src 'none'; base-uri 'self'; child-src github.githubassets.com github.com/assets-cdn/worker/ github.com/assets/ gist.github.com/assets-cdn/worker/; connect-src 'self' uploads.github.com www.githubstatus.com collector.github.com raw.githubusercontent.com api.github.com github-cloud.s3.amazonaws.com github-production-repository-file-5c1aeb.s3.amazonaws.com github-production-upload-manifest-file-7fdce7.s3.amazonaws.com github-production-user-asset-6210df.s3.amazonaws.com *.rel.tunnels.api.visualstudio.com wss://*.rel.tunnels.api.visualstudio.com objects-origin.githubusercontent.com copilot-proxy.githubusercontent.com proxy.individual.githubcopilot.com proxy.business.githubcopilot.com proxy.enterprise.githubcopilot.com *.actions.githubusercontent.com wss://*.actions.githubusercontent.com productionresultssa0.blob.core.windows.net/ productionresultssa1.blob.core.windows.net/ productionresultssa2.blob.core.windows.net/ productionresultssa3.blob.core.windows.net/ productionresultssa4.blob.core.windows.net/ productionresultssa5.blob.core.windows.net/ productionresultssa6.blob.core.windows.net/ productionresultssa7.blob.core.windows.net/ productionresultssa8.blob.core.windows.net/ productionresultssa9.blob.core.windows.net/ productionresultssa10.blob.core.windows.net/ productionresultssa11.blob.core.windows.net/ productionresultssa12.blob.core.windows.net/ productionresultssa13.blob.core.windows.net/ productionresultssa14.blob.core.windows.net/ productionresultssa15.blob.core.windows.net/ productionresultssa16.blob.core.windows.net/ productionresultssa17.blob.core.windows.net/ productionresultssa18.blob.core.windows.net/ productionresultssa19.blob.core.windows.net/ github-production-repository-image-32fea6.s3.amazonaws.com github-production-release-asset-2e65be.s3.amazonaws.com insights.github.com wss://alive.github.com api.githubcopilot.com api.individual.githubcopilot.com api.business.githubcopilot.com api.enterprise.githubcopilot.com; font-src github.githubassets.com; form-action 'self' github.com gist.github.com copilot-workspace.githubnext.com objects-origin.githubusercontent.com; frame-ancestors 'none'; frame-src viewscreen.githubusercontent.com notebooks.githubusercontent.com; img-src 'self' data: blob: github.githubassets.com media.githubusercontent.com camo.githubusercontent.com identicons.github.com avatars.githubusercontent.com private-avatars.githubusercontent.com github-cloud.s3.amazonaws.com objects.githubusercontent.com release-assets.githubusercontent.com secured-user-images.githubusercontent.com/ user-images.githubusercontent.com/ private-user-images.githubusercontent.com opengraph.githubassets.com copilotprodattachments.blob.core.windows.net/github-production-copilot-attachments/ github-production-user-asset-6210df.s3.amazonaws.com customer-stories-feed.github.com spotlights-feed.github.com objects-origin.githubusercontent.com *.githubusercontent.com; manifest-src 'self'; media-src github.com user-images.githubusercontent.com/ secured-user-images.githubusercontent.com/ private-user-images.githubusercontent.com github-production-user-asset-6210df.s3.amazonaws.com gist.github.com; script-src github.githubassets.com; style-src 'unsafe-inline' github.githubassets.com; upgrade-insecure-requests; worker-src github.githubassets.com github.com/assets-cdn/worker/ github.com/assets/ gist.github.com/assets-cdn/worker/
server: github.com
set-cookie: _gh_sess=zLbHkt4fhFfifrqdH8NsF4kvwlSkqq2VOHPxpBAAgfIjGDlFPPAdBpqq0biD2Fl4BKmLa23FrtwHBDeDrutSwaEFFhqeTyAahTaugUz8gLe1YfxSoOIBMo9pJVnBvHDH%2BmMUjas94Q6C1CV0nRD8ZEcweI3uRqtDIOfOu88g4p1Y%2FRQkG1wsyzQSz6mf18Ftm%2FqXZoVh5RgZLNoZGfnqzzZkqMeFrn81qNDF4t%2B2WEf%2B0e2hEaHFyflK72VHkpLZKUTgZkHAWWzP1iM0Dc2cxA%3D%3D--njRieWlwsRcLgEt1--%2F5vUjOoP0SpT3YDrAIcKXg%3D%3D; Path=/; HttpOnly; Secure; SameSite=Lax
set-cookie: _octo=GH1.1.1314696963.1753809588; Path=/; Domain=github.com; Expires=Wed, 29 Jul 2026 17:19:48 GMT; Secure; SameSite=Lax
set-cookie: logged_in=no; Path=/; Domain=github.com; Expires=Wed, 29 Jul 2026 17:19:48 GMT; HttpOnly; Secure; SameSite=Lax
x-github-request-id: C72C:B9BC6:E6B420:110A30F:688902B4
HTTP/2 200
date: Tue, 29 Jul 2025 17:19:49 GMT
content-type: text/html; charset=utf-8
vary: X-PJAX, X-PJAX-Container, Turbo-Visit, Turbo-Frame, X-Requested-With,Accept-Encoding, Accept, X-Requested-With
x-repository-download: git clone https://github.com/databendlabs/openraft.git
etag: W/"79b24cf7aef3824f8ceabffb0e5a665c"
cache-control: max-age=0, private, must-revalidate
strict-transport-security: max-age=31536000; includeSubdomains; preload
x-frame-options: deny
x-content-type-options: nosniff
x-xss-protection: 0
referrer-policy: no-referrer-when-downgrade
content-security-policy: default-src 'none'; base-uri 'self'; child-src github.githubassets.com github.com/assets-cdn/worker/ github.com/assets/ gist.github.com/assets-cdn/worker/; connect-src 'self' uploads.github.com www.githubstatus.com collector.github.com raw.githubusercontent.com api.github.com github-cloud.s3.amazonaws.com github-production-repository-file-5c1aeb.s3.amazonaws.com github-production-upload-manifest-file-7fdce7.s3.amazonaws.com github-production-user-asset-6210df.s3.amazonaws.com *.rel.tunnels.api.visualstudio.com wss://*.rel.tunnels.api.visualstudio.com objects-origin.githubusercontent.com copilot-proxy.githubusercontent.com proxy.individual.githubcopilot.com proxy.business.githubcopilot.com proxy.enterprise.githubcopilot.com *.actions.githubusercontent.com wss://*.actions.githubusercontent.com productionresultssa0.blob.core.windows.net/ productionresultssa1.blob.core.windows.net/ productionresultssa2.blob.core.windows.net/ productionresultssa3.blob.core.windows.net/ productionresultssa4.blob.core.windows.net/ productionresultssa5.blob.core.windows.net/ productionresultssa6.blob.core.windows.net/ productionresultssa7.blob.core.windows.net/ productionresultssa8.blob.core.windows.net/ productionresultssa9.blob.core.windows.net/ productionresultssa10.blob.core.windows.net/ productionresultssa11.blob.core.windows.net/ productionresultssa12.blob.core.windows.net/ productionresultssa13.blob.core.windows.net/ productionresultssa14.blob.core.windows.net/ productionresultssa15.blob.core.windows.net/ productionresultssa16.blob.core.windows.net/ productionresultssa17.blob.core.windows.net/ productionresultssa18.blob.core.windows.net/ productionresultssa19.blob.core.windows.net/ github-production-repository-image-32fea6.s3.amazonaws.com github-production-release-asset-2e65be.s3.amazonaws.com insights.github.com wss://alive.github.com api.githubcopilot.com api.individual.githubcopilot.com api.business.githubcopilot.com api.enterprise.githubcopilot.com; font-src github.githubassets.com; form-action 'self' github.com gist.github.com copilot-workspace.githubnext.com objects-origin.githubusercontent.com; frame-ancestors 'none'; frame-src viewscreen.githubusercontent.com notebooks.githubusercontent.com; img-src 'self' data: blob: github.githubassets.com media.githubusercontent.com camo.githubusercontent.com identicons.github.com avatars.githubusercontent.com private-avatars.githubusercontent.com github-cloud.s3.amazonaws.com objects.githubusercontent.com release-assets.githubusercontent.com secured-user-images.githubusercontent.com/ user-images.githubusercontent.com/ private-user-images.githubusercontent.com opengraph.githubassets.com copilotprodattachments.blob.core.windows.net/github-production-copilot-attachments/ github-production-user-asset-6210df.s3.amazonaws.com customer-stories-feed.github.com spotlights-feed.github.com objects-origin.githubusercontent.com *.githubusercontent.com; manifest-src 'self'; media-src github.com user-images.githubusercontent.com/ secured-user-images.githubusercontent.com/ private-user-images.githubusercontent.com github-production-user-asset-6210df.s3.amazonaws.com gist.github.com; script-src github.githubassets.com; style-src 'unsafe-inline' github.githubassets.com; upgrade-insecure-requests; worker-src github.githubassets.com github.com/assets-cdn/worker/ github.com/assets/ gist.github.com/assets-cdn/worker/
server: github.com
content-encoding: gzip
accept-ranges: bytes
x-github-request-id: C72C:B9BC6:E6B453:110A348:688902B4
fix: race condition of concurrent snapshot-install and apply. · databendlabs/openraft@eed681d · GitHub
Copy file name to clipboardExpand all lines: async-raft/src/core/append_entries.rs
Copy file name to clipboardExpand all lines: async-raft/src/core/client.rs
Copy file name to clipboardExpand all lines: async-raft/src/core/install_snapshot.rs
Copy file name to clipboardExpand all lines: async-raft/src/raft_types.rs
Copy file name to clipboardExpand all lines: async-raft/tests/snapshot_overrides_membership.rs
Skip to content
Navigation Menu
{{ message }}
-
Notifications
You must be signed in to change notification settings - Fork 173
Commit eed681d
committed
fix: race condition of concurrent snapshot-install and apply.
Problem:
Concurrent snapshot-install and apply mess up `last_applied`.
`finalize_snapshot_installation` runs in the `RaftCore` thread.
`apply_to_state_machine` runs in a separate tokio task(thread).
Thus there is chance the `last_applied` being reset to a previous value:
- `apply_to_state_machine` is called and finished in a thread.
- `finalize_snapshot_installation` is called in `RaftCore` thread and
finished with `last_applied` updated.
- `RaftCore` thread finished waiting for `apply_to_state_machine`, and
updated `last_applied` to a previous value.
```
RaftCore: -. install-snapshot, .-> replicate_to_sm_handle.next(),
| update last_applied=5 | update last_applied=2
| |
v |
task: apply 2------------------------'
--------------------------------------------------------------------> time
```
Solution:
Rule: All changes to state machine must be serialized.
A temporary simple solution for now is to call all methods that modify state
machine in `RaftCore` thread.
But this way it blocks `RaftCore` thread.
A better way is to move all tasks that modifies state machine to a
standalone thread, and send update request back to `RaftCore` to update
its fields such as `last_applied`1 parent 4d58a51 commit eed681dCopy full SHA for eed681d
File tree
Expand file treeCollapse file tree
9 files changed
+94
-131
lines changedFilter options
- async-raft
- src
- core
- tests
- memstore/src
Expand file treeCollapse file tree
9 files changed
+94
-131
lines changedasync-raft/src/core/append_entries.rs
Copy file name to clipboardExpand all lines: async-raft/src/core/append_entries.rs+30-64Lines changed: 30 additions & 64 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1 |
| - | |
2 |
| - | |
3 | 1 |
| |
4 | 2 |
| |
5 | 3 |
| |
| |||
27 | 25 |
| |
28 | 26 |
| |
29 | 27 |
| |
30 |
| - | |
| 28 | + | |
31 | 29 |
| |
32 | 30 |
| |
33 | 31 |
| |
| |||
323 | 321 |
| |
324 | 322 |
| |
325 | 323 |
| |
326 |
| - | |
| 324 | + | |
327 | 325 |
| |
328 | 326 |
| |
329 | 327 |
| |
330 | 328 |
| |
331 | 329 |
| |
332 | 330 |
| |
333 | 331 |
| |
334 |
| - | |
335 |
| - | |
336 |
| - | |
337 |
| - | |
338 |
| - | |
339 |
| - | |
340 |
| - | |
| 332 | + | |
341 | 333 |
| |
342 | 334 |
| |
343 | 335 |
| |
| |||
353 | 345 |
| |
354 | 346 |
| |
355 | 347 |
| |
356 |
| - | |
357 | 348 |
| |
358 | 349 |
| |
359 | 350 |
| |
360 | 351 |
| |
361 | 352 |
| |
362 | 353 |
| |
363 |
| - | |
| 354 | + | |
364 | 355 |
| |
365 |
| - | |
| 356 | + | |
366 | 357 |
| |
367 | 358 |
| |
368 |
| - | |
369 |
| - | |
370 |
| - | |
371 |
| - | |
372 |
| - | |
373 |
| - | |
374 |
| - | |
375 |
| - | |
376 |
| - | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
377 | 364 |
| |
378 |
| - | |
379 |
| - | |
380 |
| - | |
381 |
| - | |
382 |
| - | |
383 |
| - | |
384 |
| - | |
385 |
| - | |
386 |
| - | |
387 |
| - | |
388 |
| - | |
389 |
| - | |
390 |
| - | |
391 |
| - | |
392 |
| - | |
393 |
| - | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
394 | 369 |
| |
395 | 370 |
| |
396 | 371 |
| |
| |||
399 | 374 |
| |
400 | 375 |
| |
401 | 376 |
| |
402 |
| - | |
403 |
| - | |
| 377 | + | |
| 378 | + | |
404 | 379 |
| |
405 | 380 |
| |
406 | 381 |
| |
407 | 382 |
| |
408 |
| - | |
409 |
| - | |
410 |
| - | |
411 |
| - | |
412 |
| - | |
413 | 383 |
| |
414 | 384 |
| |
415 | 385 |
| |
416 | 386 |
| |
417 | 387 |
| |
418 |
| - | |
| 388 | + | |
419 | 389 |
| |
420 | 390 |
| |
421 | 391 |
| |
422 |
| - | |
423 |
| - | |
424 |
| - | |
425 |
| - | |
426 |
| - | |
427 |
| - | |
428 |
| - | |
429 |
| - | |
430 |
| - | |
431 |
| - | |
432 |
| - | |
433 |
| - | |
434 |
| - | |
435 |
| - | |
436 |
| - | |
437 |
| - | |
438 |
| - | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
439 | 405 |
| |
440 | 406 |
|
async-raft/src/core/client.rs
Copy file name to clipboardExpand all lines: async-raft/src/core/client.rs+2-10Lines changed: 2 additions & 10 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
339 | 339 |
| |
340 | 340 |
| |
341 | 341 |
| |
342 |
| - | |
| 342 | + | |
343 | 343 |
| |
344 | 344 |
| |
345 | 345 |
| |
| |||
419 | 419 |
| |
420 | 420 |
| |
421 | 421 |
| |
422 |
| - | |
| 422 | + | |
423 | 423 |
| |
424 | 424 |
| |
425 | 425 |
| |
| |||
453 | 453 |
| |
454 | 454 |
| |
455 | 455 |
| |
456 |
| - | |
457 |
| - | |
458 |
| - | |
459 |
| - | |
460 |
| - | |
461 |
| - | |
462 |
| - | |
463 |
| - | |
464 | 456 |
| |
465 | 457 |
| |
466 | 458 |
| |
|
async-raft/src/core/install_snapshot.rs
Copy file name to clipboardExpand all lines: async-raft/src/core/install_snapshot.rs+44-9Lines changed: 44 additions & 9 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
181 | 181 |
| |
182 | 182 |
| |
183 | 183 |
| |
184 |
| - | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
185 | 200 |
| |
186 | 201 |
| |
187 |
| - | |
188 |
| - | |
189 |
| - | |
190 |
| - | |
191 |
| - | |
192 |
| - | |
193 |
| - | |
194 |
| - | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
195 | 230 |
| |
196 | 231 |
| |
197 | 232 |
|
-44Lines changed: 0 additions & 44 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
14 | 14 |
| |
15 | 15 |
| |
16 | 16 |
| |
17 |
| - | |
18 |
| - | |
19 | 17 |
| |
20 | 18 |
| |
21 | 19 |
| |
| |||
120 | 118 |
| |
121 | 119 |
| |
122 | 120 |
| |
123 |
| - | |
124 |
| - | |
125 |
| - | |
126 |
| - | |
127 |
| - | |
128 |
| - | |
129 |
| - | |
130 | 121 |
| |
131 | 122 |
| |
132 | 123 |
| |
| |||
171 | 162 |
| |
172 | 163 |
| |
173 | 164 |
| |
174 |
| - | |
175 | 165 |
| |
176 | 166 |
| |
177 | 167 |
| |
| |||
464 | 454 |
| |
465 | 455 |
| |
466 | 456 |
| |
467 |
| - | |
468 |
| - | |
469 |
| - | |
470 |
| - | |
471 |
| - | |
472 |
| - | |
473 |
| - | |
474 |
| - | |
475 |
| - | |
476 |
| - | |
477 |
| - | |
478 |
| - | |
479 |
| - | |
480 |
| - | |
481 |
| - | |
482 |
| - | |
483 | 457 |
| |
484 | 458 |
| |
485 | 459 |
| |
| |||
731 | 705 |
| |
732 | 706 |
| |
733 | 707 |
| |
734 |
| - | |
735 |
| - | |
736 |
| - | |
737 |
| - | |
738 |
| - | |
739 |
| - | |
740 | 708 |
| |
741 | 709 |
| |
742 | 710 |
| |
| |||
909 | 877 |
| |
910 | 878 |
| |
911 | 879 |
| |
912 |
| - | |
913 |
| - | |
914 |
| - | |
915 |
| - | |
916 | 880 |
| |
917 | 881 |
| |
918 | 882 |
| |
| |||
980 | 944 |
| |
981 | 945 |
| |
982 | 946 |
| |
983 |
| - | |
984 |
| - | |
985 |
| - | |
986 |
| - | |
987 | 947 |
| |
988 | 948 |
| |
989 | 949 |
| |
| |||
1047 | 1007 |
| |
1048 | 1008 |
| |
1049 | 1009 |
| |
1050 |
| - | |
1051 |
| - | |
1052 |
| - | |
1053 |
| - | |
1054 | 1010 |
| |
1055 | 1011 |
| |
1056 | 1012 |
| |
|
+1Lines changed: 1 addition & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
33 | 33 |
| |
34 | 34 |
| |
35 | 35 |
| |
| 36 | + | |
36 | 37 |
| |
37 | 38 |
| |
38 | 39 |
| |
|
async-raft/src/raft_types.rs
Copy file name to clipboardExpand all lines: async-raft/src/raft_types.rs+8Lines changed: 8 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
55 | 55 |
| |
56 | 56 |
| |
57 | 57 |
| |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + |
+2-1Lines changed: 2 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
15 | 15 |
| |
16 | 16 |
| |
17 | 17 |
| |
| 18 | + | |
18 | 19 |
| |
19 | 20 |
| |
20 | 21 |
| |
| |||
269 | 270 |
| |
270 | 271 |
| |
271 | 272 |
| |
272 |
| - | |
| 273 | + | |
273 | 274 |
| |
274 | 275 |
| |
275 | 276 |
| |
|
async-raft/tests/snapshot_overrides_membership.rs
Copy file name to clipboardExpand all lines: async-raft/tests/snapshot_overrides_membership.rs+1-1Lines changed: 1 addition & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
29 | 29 |
| |
30 | 30 |
| |
31 | 31 |
| |
32 |
| - | |
| 32 | + | |
33 | 33 |
| |
34 | 34 |
| |
35 | 35 |
| |
|
You can’t perform that action at this time.
0 commit comments