Commit 93ec6c7
authored
fix(tree): commit enrichment after transaction abort (microsoft#25978)
## Description
Aborting a transaction used to put the tree in a state that would
trigger an assert when sending some undo/redo edits to peers.
This would prevent some undo/redo edits from being sent and would put
the tree in a broken state that prevented any further edits.
This issue could not have caused document corruption, so reopening the
document was a possible remedy.
After this PR, aborting a transaction no longer puts the tree in such a
state, so it is safe to perform undo/redo edits after that.
This bug was due to the fact that `TreeCheckout` overwrote its
`DetachedFieldIndex` member with a new instance when performing a
transaction rollback but had no way of informing the
`SharedTreeReadonlyChangeEnricher` that it should now be reading from
the new instance during change enrichment.
This PR fixes the bug by ensuring that a given `TreeCheckout` instance
always uses the same `DetachedFieldIndex` instance. This requires
introducing a way of snapshotting and (on transaction rollback)
restoring the `DetachedFieldIndex` state that does not require replacing
the instance.
This PR also reduces the `DetachedFieldIndex` API surface made available
to `SharedTreeReadonlyChangeEnricher` by introducing the
`ReadOnlyDetachedFieldIndex` interface. This is not required as part of
this change and could be done in a separate PR.
## Breaking Changes
None
## Reviewer Guidance
Let me know if you think it's worth spinning up a separate PR for the
introduction of `ReadOnlyDetachedFieldIndex`.1 parent b0513a6 commit 93ec6c7
File tree
9 files changed
+233
-53
lines changed- .changeset
- packages/dds/tree/src
- core
- tree
- test
- core/tree
9 files changed
+233
-53
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
83 | 83 | | |
84 | 84 | | |
85 | 85 | | |
| 86 | + | |
| 87 | + | |
86 | 88 | | |
87 | 89 | | |
88 | 90 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
37 | 37 | | |
38 | 38 | | |
39 | 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 | + | |
40 | 74 | | |
41 | 75 | | |
42 | 76 | | |
43 | | - | |
| 77 | + | |
44 | 78 | | |
45 | 79 | | |
46 | 80 | | |
| |||
106 | 140 | | |
107 | 141 | | |
108 | 142 | | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
109 | 162 | | |
110 | 163 | | |
111 | 164 | | |
| |||
201 | 254 | | |
202 | 255 | | |
203 | 256 | | |
204 | | - | |
205 | | - | |
206 | | - | |
207 | | - | |
208 | 257 | | |
209 | 258 | | |
210 | 259 | | |
211 | 260 | | |
212 | | - | |
213 | | - | |
214 | | - | |
215 | | - | |
216 | 261 | | |
217 | 262 | | |
218 | 263 | | |
219 | 264 | | |
220 | | - | |
221 | | - | |
222 | | - | |
223 | | - | |
224 | 265 | | |
225 | 266 | | |
226 | 267 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
117 | 117 | | |
118 | 118 | | |
119 | 119 | | |
120 | | - | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
121 | 125 | | |
122 | 126 | | |
123 | 127 | | |
| |||
Lines changed: 31 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
| 13 | + | |
12 | 14 | | |
13 | 15 | | |
14 | 16 | | |
| |||
35 | 37 | | |
36 | 38 | | |
37 | 39 | | |
38 | | - | |
39 | | - | |
| 40 | + | |
| 41 | + | |
40 | 42 | | |
41 | | - | |
42 | | - | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
43 | 46 | | |
44 | 47 | | |
45 | | - | |
| 48 | + | |
46 | 49 | | |
47 | | - | |
| 50 | + | |
48 | 51 | | |
49 | 52 | | |
50 | 53 | | |
51 | 54 | | |
52 | 55 | | |
53 | | - | |
| 56 | + | |
54 | 57 | | |
55 | | - | |
| 58 | + | |
56 | 59 | | |
57 | 60 | | |
58 | 61 | | |
| |||
66 | 69 | | |
67 | 70 | | |
68 | 71 | | |
69 | | - | |
| 72 | + | |
70 | 73 | | |
71 | | - | |
72 | | - | |
| 74 | + | |
| 75 | + | |
73 | 76 | | |
74 | 77 | | |
75 | 78 | | |
| |||
85 | 88 | | |
86 | 89 | | |
87 | 90 | | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
88 | 108 | | |
89 | 109 | | |
90 | 110 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
| 51 | + | |
51 | 52 | | |
52 | 53 | | |
53 | 54 | | |
| |||
406 | 407 | | |
407 | 408 | | |
408 | 409 | | |
409 | | - | |
| 410 | + | |
410 | 411 | | |
411 | 412 | | |
412 | 413 | | |
| |||
421 | 422 | | |
422 | 423 | | |
423 | 424 | | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
424 | 429 | | |
425 | 430 | | |
426 | 431 | | |
| |||
441 | 446 | | |
442 | 447 | | |
443 | 448 | | |
444 | | - | |
| 449 | + | |
445 | 450 | | |
446 | 451 | | |
447 | 452 | | |
| |||
452 | 457 | | |
453 | 458 | | |
454 | 459 | | |
455 | | - | |
456 | | - | |
| 460 | + | |
| 461 | + | |
457 | 462 | | |
458 | 463 | | |
459 | 464 | | |
460 | | - | |
| 465 | + | |
461 | 466 | | |
462 | 467 | | |
463 | 468 | | |
| |||
566 | 571 | | |
567 | 572 | | |
568 | 573 | | |
569 | | - | |
| 574 | + | |
570 | 575 | | |
571 | 576 | | |
572 | 577 | | |
| |||
597 | 602 | | |
598 | 603 | | |
599 | 604 | | |
600 | | - | |
| 605 | + | |
601 | 606 | | |
602 | 607 | | |
603 | 608 | | |
604 | | - | |
| 609 | + | |
605 | 610 | | |
606 | 611 | | |
607 | | - | |
| 612 | + | |
608 | 613 | | |
609 | 614 | | |
610 | 615 | | |
| |||
774 | 779 | | |
775 | 780 | | |
776 | 781 | | |
777 | | - | |
| 782 | + | |
778 | 783 | | |
779 | 784 | | |
780 | 785 | | |
| |||
894 | 899 | | |
895 | 900 | | |
896 | 901 | | |
897 | | - | |
898 | | - | |
| 902 | + | |
| 903 | + | |
899 | 904 | | |
900 | 905 | | |
901 | 906 | | |
| |||
915 | 920 | | |
916 | 921 | | |
917 | 922 | | |
918 | | - | |
| 923 | + | |
919 | 924 | | |
920 | 925 | | |
921 | 926 | | |
| |||
987 | 992 | | |
988 | 993 | | |
989 | 994 | | |
990 | | - | |
991 | | - | |
| 995 | + | |
| 996 | + | |
992 | 997 | | |
993 | 998 | | |
994 | 999 | | |
| |||
0 commit comments