Commit a0fa3ec
committed
[#33444] DocDB: Orchestrate the index-backfill ordering-generation lifecycle from the master
The persisted ordering generation (#33580) had no production lifecycle: nothing
activated it before marked backfill writes, nothing released it, and the
master-side split suppression protecting a backfill is in-memory only (lost on
failover). This part wires the full lifecycle and flips marked-write gating
fail-closed.
Activation rides ChangeMetadataOperation (a new
`ChangeMetadataRequestPB.index_backfill_ordering_generation` variant, applied
via `Tablet::UpdateIndexBackfillOrderingGeneration` exactly like
`mark_backfill_done`): Raft-replicated, follower-applied, WAL-replayed, and
`base_op_index` is the activation operation's own Raft index, so every replica
and every replay derives the same base with no master-side bookkeeping.
Re-activation (failover resume) is idempotent -- the base only moves up.
Master flow, SKIP_ALL jobs on PGSQL indexed tables only (the mode rides YSQL
chunk requests; YCQL backfill writes are never marked, so generations would
only fence their splits without protecting anything):
- Before the first chunk (`DoBackfill`), the job disables and drains
index-table splitting, then fans out one waited
`UpdateOrderingGenerationForTablet` task per index tablet (the
`GetSafeTimeForTablet` join pattern). All acks -> chunks launch; any failure
-> the job aborts before a single marked write exists, and CREATE INDEX
fails cleanly. The drain closes the activation/split TOCTOU: consensus
already rejects CHANGE_METADATA_OP while a split is pending, the generation
fence rejects splits after activation applies, and a split appended in the
append-to-apply window can at worst fail the activation task -- never
corrupt a scan set that marked writes exist in.
- Release is fire-and-forget from the terminal funnel
(`UpdateIndexPermissionsForIndexes`), which every success/failure/abort path
traverses. The tserver metadata validator converges stragglers, mirroring
the retain_delete_markers machinery: tablets with an active generation join
its existing GetBackfillStatus poll, and the generation is released locally
(no Raft) once the master reports a terminal state. `IndexStatusPB` gains
`BACKFILL_FAILED` (removal-path index permissions map to it) so a failed
SKIP_ALL job whose funnel release was lost cannot leave an orphaned invalid
index permanently split-fenced and retention-pinned; the
retain_delete_markers heal itself stays success-only.
- The tablet-split manager refuses to split an index whose indexed table has a
durable SKIP_ALL backfill job. The manager's table validation takes no
catalog locks itself -- the indexed table is a caller-resolved parameter,
because the manual-split path enters through ValidateSplitCandidateUnlocked
with the catalog mutex already held (a recursive shared acquisition is fatal
under lock_debug) (`SysTablesEntryPB.backfill_jobs`, survives
failover, cleared in the funnel), with an INFO-level skip reason -- today's
two in-memory suppressions cover only the indexed table and evaporate on
failover. The tablet-side generation fence stays as the fail-closed layer.
Gating flip: `WriteOperation::ValidateLeaderOpId` now rejects marked writes
with *no* active generation (previously deferred) -- a marked write outside a
generation would store versions nothing tracks or releases (e.g. a stale chunk
retry after the job's terminal state). Tests that drive marked writes directly
now activate a generation first.
`write_id_floor_version` numbering lands as
`kIndexBackfillWriteIdFloorVersion = 1`.
The mode selector remains hardcoded to CHECK_ALL (#33484), so this whole flow
stays production-unreachable; tests drive it through the master-side TEST
override.
Test Plan:
./yb_build.sh release --cxx-test tablet_peer-test --gtest_filter 'TabletPeerTest.OrderingGenerationChangeMetadataOpSetsBaseFromOwnRaftIndex'
./yb_build.sh release --cxx-test tablet_peer-test --gtest_filter 'TabletPeerTest.FixedHybridTimeWriteRejectedAtOrBelowGenerationBase'
./yb_build.sh release --cxx-test pg_index_backfill-test --gtest_filter 'PgIndexBackfillSkipAllRaftOrdering.OrderingGenerationActivatedAndReleased/0'
./yb_build.sh release --cxx-test pg_index_backfill-test --gtest_filter 'PgIndexBackfillSkipAllActivationFailure.ActivationFailureFailsCreateIndexCleanly/0'
./yb_build.sh release --cxx-test pg_index_backfill-test --gtest_filter 'PgIndexBackfillSkipAllBlocked.SplitFencedDuringBackfill/0'
Retrofitted (marked writes now require an active generation):
./yb_build.sh release --cxx-test tablet_peer-test --gtest_filter 'TabletPeerTest.FixedHybridTimeWrite*'
./yb_build.sh release --cxx-test fixed_hybrid_time_write_id-itest
Regressions: skip_all e2e + marker canary through the real activation flow,
uniq-idx-1 mode tests, DuplicatesExistBeforeBackfill, 3b-i generation tests,
0a/0b abort tests, and drop-path tests for the permissions mapping change
(PgIndexBackfillTest.Drop, PgIndexBackfillFastClientTimeout.DropWhileBackfilling)
-- all green.
Assisted-By: devx/08801cf6-2854-4c6f-a378-1d98d239b22d
---
_automated · Claude Fable 5 (opencode)_1 parent cc9ba40 commit a0fa3ec
26 files changed
Lines changed: 825 additions & 56 deletions
File tree
- src/yb
- common
- integration-tests
- master
- server
- tablet
- operations
- tserver
- yql/pgwrapper
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
57 | 63 | | |
58 | 64 | | |
59 | 65 | | |
| |||
Lines changed: 7 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
285 | 285 | | |
286 | 286 | | |
287 | 287 | | |
| 288 | + | |
288 | 289 | | |
289 | 290 | | |
290 | 291 | | |
| |||
344 | 345 | | |
345 | 346 | | |
346 | 347 | | |
| 348 | + | |
347 | 349 | | |
348 | 350 | | |
349 | 351 | | |
| |||
355 | 357 | | |
356 | 358 | | |
357 | 359 | | |
358 | | - | |
359 | | - | |
360 | | - | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
361 | 363 | | |
362 | 364 | | |
363 | 365 | | |
| |||
393 | 395 | | |
394 | 396 | | |
395 | 397 | | |
| 398 | + | |
396 | 399 | | |
397 | 400 | | |
398 | | - | |
399 | 401 | | |
400 | 402 | | |
401 | 403 | | |
| |||
464 | 466 | | |
465 | 467 | | |
466 | 468 | | |
| 469 | + | |
467 | 470 | | |
468 | 471 | | |
469 | 472 | | |
470 | 473 | | |
471 | 474 | | |
472 | 475 | | |
473 | | - | |
474 | 476 | | |
475 | 477 | | |
476 | 478 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
970 | 970 | | |
971 | 971 | | |
972 | 972 | | |
973 | | - | |
| 973 | + | |
| 974 | + | |
974 | 975 | | |
975 | 976 | | |
976 | | - | |
| 977 | + | |
| 978 | + | |
977 | 979 | | |
978 | 980 | | |
979 | 981 | | |
| |||
2762 | 2764 | | |
2763 | 2765 | | |
2764 | 2766 | | |
2765 | | - | |
| 2767 | + | |
| 2768 | + | |
2766 | 2769 | | |
2767 | 2770 | | |
2768 | 2771 | | |
2769 | 2772 | | |
2770 | | - | |
| 2773 | + | |
| 2774 | + | |
2771 | 2775 | | |
2772 | 2776 | | |
2773 | 2777 | | |
2774 | | - | |
| 2778 | + | |
| 2779 | + | |
2775 | 2780 | | |
2776 | 2781 | | |
2777 | 2782 | | |
2778 | 2783 | | |
2779 | 2784 | | |
2780 | | - | |
2781 | | - | |
| 2785 | + | |
| 2786 | + | |
2782 | 2787 | | |
2783 | 2788 | | |
2784 | 2789 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
| 35 | + | |
35 | 36 | | |
36 | 37 | | |
37 | 38 | | |
| |||
1076 | 1077 | | |
1077 | 1078 | | |
1078 | 1079 | | |
| 1080 | + | |
| 1081 | + | |
| 1082 | + | |
| 1083 | + | |
| 1084 | + | |
| 1085 | + | |
| 1086 | + | |
| 1087 | + | |
| 1088 | + | |
| 1089 | + | |
| 1090 | + | |
| 1091 | + | |
1079 | 1092 | | |
1080 | 1093 | | |
1081 | 1094 | | |
| |||
1086 | 1099 | | |
1087 | 1100 | | |
1088 | 1101 | | |
| 1102 | + | |
| 1103 | + | |
| 1104 | + | |
| 1105 | + | |
| 1106 | + | |
| 1107 | + | |
| 1108 | + | |
| 1109 | + | |
| 1110 | + | |
| 1111 | + | |
| 1112 | + | |
| 1113 | + | |
| 1114 | + | |
| 1115 | + | |
| 1116 | + | |
| 1117 | + | |
| 1118 | + | |
| 1119 | + | |
| 1120 | + | |
| 1121 | + | |
| 1122 | + | |
| 1123 | + | |
| 1124 | + | |
| 1125 | + | |
| 1126 | + | |
| 1127 | + | |
| 1128 | + | |
| 1129 | + | |
| 1130 | + | |
| 1131 | + | |
| 1132 | + | |
| 1133 | + | |
| 1134 | + | |
| 1135 | + | |
| 1136 | + | |
| 1137 | + | |
| 1138 | + | |
| 1139 | + | |
| 1140 | + | |
| 1141 | + | |
| 1142 | + | |
| 1143 | + | |
| 1144 | + | |
| 1145 | + | |
| 1146 | + | |
| 1147 | + | |
| 1148 | + | |
| 1149 | + | |
| 1150 | + | |
| 1151 | + | |
| 1152 | + | |
| 1153 | + | |
| 1154 | + | |
| 1155 | + | |
| 1156 | + | |
| 1157 | + | |
| 1158 | + | |
| 1159 | + | |
| 1160 | + | |
| 1161 | + | |
| 1162 | + | |
| 1163 | + | |
| 1164 | + | |
| 1165 | + | |
| 1166 | + | |
| 1167 | + | |
| 1168 | + | |
| 1169 | + | |
| 1170 | + | |
| 1171 | + | |
| 1172 | + | |
| 1173 | + | |
| 1174 | + | |
| 1175 | + | |
| 1176 | + | |
| 1177 | + | |
| 1178 | + | |
| 1179 | + | |
| 1180 | + | |
| 1181 | + | |
| 1182 | + | |
| 1183 | + | |
| 1184 | + | |
| 1185 | + | |
| 1186 | + | |
| 1187 | + | |
| 1188 | + | |
| 1189 | + | |
| 1190 | + | |
| 1191 | + | |
| 1192 | + | |
| 1193 | + | |
| 1194 | + | |
| 1195 | + | |
| 1196 | + | |
| 1197 | + | |
| 1198 | + | |
| 1199 | + | |
| 1200 | + | |
| 1201 | + | |
| 1202 | + | |
| 1203 | + | |
| 1204 | + | |
| 1205 | + | |
| 1206 | + | |
| 1207 | + | |
| 1208 | + | |
| 1209 | + | |
| 1210 | + | |
| 1211 | + | |
| 1212 | + | |
| 1213 | + | |
| 1214 | + | |
| 1215 | + | |
| 1216 | + | |
| 1217 | + | |
| 1218 | + | |
| 1219 | + | |
| 1220 | + | |
| 1221 | + | |
1089 | 1222 | | |
1090 | 1223 | | |
1091 | 1224 | | |
| |||
1316 | 1449 | | |
1317 | 1450 | | |
1318 | 1451 | | |
| 1452 | + | |
| 1453 | + | |
| 1454 | + | |
| 1455 | + | |
| 1456 | + | |
| 1457 | + | |
| 1458 | + | |
1319 | 1459 | | |
1320 | 1460 | | |
1321 | 1461 | | |
| |||
1666 | 1806 | | |
1667 | 1807 | | |
1668 | 1808 | | |
| 1809 | + | |
| 1810 | + | |
| 1811 | + | |
| 1812 | + | |
| 1813 | + | |
| 1814 | + | |
| 1815 | + | |
| 1816 | + | |
| 1817 | + | |
| 1818 | + | |
| 1819 | + | |
| 1820 | + | |
| 1821 | + | |
| 1822 | + | |
| 1823 | + | |
| 1824 | + | |
| 1825 | + | |
| 1826 | + | |
| 1827 | + | |
| 1828 | + | |
| 1829 | + | |
| 1830 | + | |
| 1831 | + | |
| 1832 | + | |
| 1833 | + | |
| 1834 | + | |
| 1835 | + | |
| 1836 | + | |
| 1837 | + | |
| 1838 | + | |
| 1839 | + | |
| 1840 | + | |
| 1841 | + | |
| 1842 | + | |
| 1843 | + | |
| 1844 | + | |
| 1845 | + | |
| 1846 | + | |
| 1847 | + | |
| 1848 | + | |
| 1849 | + | |
| 1850 | + | |
| 1851 | + | |
| 1852 | + | |
| 1853 | + | |
| 1854 | + | |
| 1855 | + | |
| 1856 | + | |
| 1857 | + | |
| 1858 | + | |
| 1859 | + | |
| 1860 | + | |
| 1861 | + | |
| 1862 | + | |
| 1863 | + | |
| 1864 | + | |
| 1865 | + | |
| 1866 | + | |
| 1867 | + | |
| 1868 | + | |
| 1869 | + | |
| 1870 | + | |
| 1871 | + | |
| 1872 | + | |
| 1873 | + | |
| 1874 | + | |
| 1875 | + | |
| 1876 | + | |
| 1877 | + | |
| 1878 | + | |
| 1879 | + | |
| 1880 | + | |
| 1881 | + | |
| 1882 | + | |
| 1883 | + | |
| 1884 | + | |
| 1885 | + | |
| 1886 | + | |
| 1887 | + | |
| 1888 | + | |
| 1889 | + | |
| 1890 | + | |
| 1891 | + | |
| 1892 | + | |
| 1893 | + | |
| 1894 | + | |
| 1895 | + | |
| 1896 | + | |
| 1897 | + | |
| 1898 | + | |
| 1899 | + | |
| 1900 | + | |
| 1901 | + | |
| 1902 | + | |
| 1903 | + | |
| 1904 | + | |
| 1905 | + | |
| 1906 | + | |
| 1907 | + | |
| 1908 | + | |
| 1909 | + | |
| 1910 | + | |
| 1911 | + | |
| 1912 | + | |
| 1913 | + | |
| 1914 | + | |
| 1915 | + | |
| 1916 | + | |
| 1917 | + | |
1669 | 1918 | | |
1670 | 1919 | | |
1671 | 1920 | | |
| |||
0 commit comments