Commit 0a4cb9c
committed
adapter: linearize a read-then-write that matched no rows
The OCC path linearizes its `as_of` before subscribing, but the subscribe
then follows Persist, and Persist runs ahead of the timestamp oracle. Group
commit appends to the txns shard first, which makes the write readable and
advances the table's upper, and calls `oracle.apply_write` only after.
A read-then-write whose selection consolidates to empty inside that window
concluded from state no oracle-timestamped read could reach yet, and
returned immediately because it had nothing to write. A
strict-serializable read issued after that response then still saw the
rows the response said were not there. Real time orders the read last and
no serial order explains the history.
Only the zero-row exits are exposed. A write is linearized for free,
because group commit answers the writer after applying the timestamp, and
the coordinator's path takes its read timestamp from the oracle and so
cannot observe state the oracle has not reached.
`OccOutcome` now separates the two cases rather than encoding "nothing to
write" as a `Committed` with no timestamp. `NoRowsMatched` carries the
timestamp emptiness was concluded at, and the caller waits for the oracle
to reach it before responding. The timestamp is absent only for a
selection that reads no persisted state, which has nothing to linearize
against. Waiting is what the existing `ensure_read_linearized` does, and
it is preferable to applying the write timestamp ourselves: forcing the
oracle forward off another writer's timestamp would stall subsequent reads
of unrelated collections until they caught up.
The `group_commit_before_apply_write` failpoint holds the window open, and
is the same one a second `environmentd` opens on its own with no ordering
against local Persist visibility.
Two mzcompose tests come with this.
`workflow_test_occ_zero_row_write_linearization` is the regression test.
It parks the winning DELETE inside the window, confirms from a
serializable read that the delete is visible in Persist and from a
strict-serializable read that the oracle cannot serve it yet, and only
then runs the UPDATE that has to report zero rows. Attempts where the
subscribe reported progress before the append, told apart by the write
conflict count, prove nothing and are retried.
`workflow_mixed_mode_read_then_write` is a guard rather than a regression
test. The dyncfg is sampled once per process, so a rolling restart can
leave one instance sequencing on the coordinator behind in-process write
locks and another under OCC. Those locks never excluded a second process,
so this is not new, but what keeps the two from corrupting a row is the
catalog fence, and nothing states that. The test asserts the fence keeps
the commit windows disjoint, so it goes red if that stops holding.1 parent 358e26f commit 0a4cb9c
5 files changed
Lines changed: 503 additions & 19 deletions
File tree
- ci/nightly
- src/adapter/src
- coord
- test
- cluster
- txn-wal-fencing
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2395 | 2395 | | |
2396 | 2396 | | |
2397 | 2397 | | |
| 2398 | + | |
| 2399 | + | |
| 2400 | + | |
| 2401 | + | |
| 2402 | + | |
| 2403 | + | |
| 2404 | + | |
| 2405 | + | |
| 2406 | + | |
| 2407 | + | |
| 2408 | + | |
2398 | 2409 | | |
2399 | 2410 | | |
2400 | 2411 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
589 | 589 | | |
590 | 590 | | |
591 | 591 | | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
592 | 602 | | |
593 | 603 | | |
594 | 604 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
171 | 171 | | |
172 | 172 | | |
173 | 173 | | |
174 | | - | |
| 174 | + | |
175 | 175 | | |
176 | 176 | | |
177 | | - | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
178 | 190 | | |
179 | 191 | | |
180 | 192 | | |
| |||
505 | 517 | | |
506 | 518 | | |
507 | 519 | | |
508 | | - | |
509 | | - | |
510 | | - | |
| 520 | + | |
511 | 521 | | |
512 | 522 | | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
513 | 541 | | |
514 | 542 | | |
515 | 543 | | |
| |||
840 | 868 | | |
841 | 869 | | |
842 | 870 | | |
843 | | - | |
844 | | - | |
| 871 | + | |
| 872 | + | |
| 873 | + | |
| 874 | + | |
845 | 875 | | |
846 | 876 | | |
847 | 877 | | |
| |||
893 | 923 | | |
894 | 924 | | |
895 | 925 | | |
896 | | - | |
| 926 | + | |
897 | 927 | | |
898 | | - | |
| 928 | + | |
899 | 929 | | |
900 | 930 | | |
901 | 931 | | |
| |||
940 | 970 | | |
941 | 971 | | |
942 | 972 | | |
943 | | - | |
944 | | - | |
| 973 | + | |
| 974 | + | |
945 | 975 | | |
946 | | - | |
| 976 | + | |
947 | 977 | | |
948 | 978 | | |
949 | 979 | | |
| |||
1036 | 1066 | | |
1037 | 1067 | | |
1038 | 1068 | | |
1039 | | - | |
| 1069 | + | |
1040 | 1070 | | |
1041 | 1071 | | |
1042 | 1072 | | |
| |||
1085 | 1115 | | |
1086 | 1116 | | |
1087 | 1117 | | |
1088 | | - | |
1089 | | - | |
| 1118 | + | |
| 1119 | + | |
1090 | 1120 | | |
1091 | | - | |
| 1121 | + | |
1092 | 1122 | | |
1093 | 1123 | | |
1094 | 1124 | | |
| |||
1314 | 1344 | | |
1315 | 1345 | | |
1316 | 1346 | | |
1317 | | - | |
1318 | | - | |
| 1347 | + | |
| 1348 | + | |
| 1349 | + | |
| 1350 | + | |
| 1351 | + | |
| 1352 | + | |
| 1353 | + | |
1319 | 1354 | | |
1320 | 1355 | | |
1321 | 1356 | | |
| |||
1398 | 1433 | | |
1399 | 1434 | | |
1400 | 1435 | | |
1401 | | - | |
| 1436 | + | |
1402 | 1437 | | |
1403 | 1438 | | |
1404 | 1439 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4638 | 4638 | | |
4639 | 4639 | | |
4640 | 4640 | | |
| 4641 | + | |
| 4642 | + | |
| 4643 | + | |
| 4644 | + | |
| 4645 | + | |
| 4646 | + | |
| 4647 | + | |
| 4648 | + | |
| 4649 | + | |
| 4650 | + | |
| 4651 | + | |
| 4652 | + | |
| 4653 | + | |
| 4654 | + | |
| 4655 | + | |
| 4656 | + | |
| 4657 | + | |
| 4658 | + | |
| 4659 | + | |
| 4660 | + | |
| 4661 | + | |
| 4662 | + | |
| 4663 | + | |
| 4664 | + | |
| 4665 | + | |
| 4666 | + | |
| 4667 | + | |
| 4668 | + | |
| 4669 | + | |
| 4670 | + | |
| 4671 | + | |
| 4672 | + | |
| 4673 | + | |
| 4674 | + | |
| 4675 | + | |
| 4676 | + | |
| 4677 | + | |
| 4678 | + | |
| 4679 | + | |
| 4680 | + | |
| 4681 | + | |
| 4682 | + | |
| 4683 | + | |
| 4684 | + | |
| 4685 | + | |
| 4686 | + | |
| 4687 | + | |
| 4688 | + | |
| 4689 | + | |
| 4690 | + | |
| 4691 | + | |
| 4692 | + | |
| 4693 | + | |
| 4694 | + | |
| 4695 | + | |
| 4696 | + | |
| 4697 | + | |
| 4698 | + | |
| 4699 | + | |
| 4700 | + | |
| 4701 | + | |
| 4702 | + | |
| 4703 | + | |
| 4704 | + | |
| 4705 | + | |
| 4706 | + | |
| 4707 | + | |
| 4708 | + | |
| 4709 | + | |
| 4710 | + | |
| 4711 | + | |
| 4712 | + | |
| 4713 | + | |
| 4714 | + | |
| 4715 | + | |
| 4716 | + | |
| 4717 | + | |
| 4718 | + | |
| 4719 | + | |
| 4720 | + | |
| 4721 | + | |
| 4722 | + | |
| 4723 | + | |
| 4724 | + | |
| 4725 | + | |
| 4726 | + | |
| 4727 | + | |
| 4728 | + | |
| 4729 | + | |
| 4730 | + | |
| 4731 | + | |
| 4732 | + | |
| 4733 | + | |
| 4734 | + | |
| 4735 | + | |
| 4736 | + | |
| 4737 | + | |
| 4738 | + | |
| 4739 | + | |
| 4740 | + | |
| 4741 | + | |
| 4742 | + | |
| 4743 | + | |
| 4744 | + | |
| 4745 | + | |
| 4746 | + | |
| 4747 | + | |
| 4748 | + | |
| 4749 | + | |
| 4750 | + | |
| 4751 | + | |
| 4752 | + | |
| 4753 | + | |
| 4754 | + | |
| 4755 | + | |
| 4756 | + | |
| 4757 | + | |
| 4758 | + | |
| 4759 | + | |
| 4760 | + | |
| 4761 | + | |
| 4762 | + | |
| 4763 | + | |
| 4764 | + | |
| 4765 | + | |
| 4766 | + | |
| 4767 | + | |
| 4768 | + | |
| 4769 | + | |
| 4770 | + | |
| 4771 | + | |
| 4772 | + | |
| 4773 | + | |
| 4774 | + | |
| 4775 | + | |
| 4776 | + | |
| 4777 | + | |
| 4778 | + | |
| 4779 | + | |
| 4780 | + | |
| 4781 | + | |
| 4782 | + | |
| 4783 | + | |
| 4784 | + | |
| 4785 | + | |
| 4786 | + | |
| 4787 | + | |
| 4788 | + | |
| 4789 | + | |
| 4790 | + | |
| 4791 | + | |
| 4792 | + | |
| 4793 | + | |
| 4794 | + | |
| 4795 | + | |
4641 | 4796 | | |
4642 | 4797 | | |
4643 | 4798 | | |
| |||
0 commit comments