Commit b5c936f
committed
[fix](cloud)(restore) fix broken schema during restore of lsc=false tables
When restoring a `light_schema_change=false` table from a shared-nothing
cluster to a shared-storage cluster, the tablet schema created by
`create_tablet` has all column `unique_id` set to -1. Later,
`commit_restore_job` writes rowset meta that contains the correct schema
(with valid `unique_id >= 0`). However, `put_schema_kv` skips writing
when the schema key already exists, leaving the broken schema
(`unique_id = -1`) in place and causing subsequent reads to fail.
Fix:
1. Introduce a new helper `put_schema_kv_on_restore` in
`meta_service_schema.{h,cpp}`. It checks the existing schema value;
if the key does not exist, or the existing schema is unparsable, or
the first column's `unique_id` is -1 (i.e. broken), it removes the
old key (range-remove to cover blob format) and writes the correct
schema. The original `put_schema_kv` interface is kept untouched.
2. In `commit_restore_job`, replace `put_schema_kv` with
`put_schema_kv_on_restore` for both rowset-meta and tablet-meta
branches. A `std::set<std::string> restored_schema_keys` is added to
avoid redundant FDB get/put for the same `(index_id, schema_version)`
within a single restore job.
3. Log `rs_meta_schema_put_cnt / skip_cnt` and
`tablet_meta_schema_put_cnt / skip_cnt` tags for observability.1 parent 2a8afb9 commit b5c936f
3 files changed
Lines changed: 73 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
| 44 | + | |
44 | 45 | | |
45 | 46 | | |
46 | 47 | | |
| |||
1764 | 1765 | | |
1765 | 1766 | | |
1766 | 1767 | | |
| 1768 | + | |
| 1769 | + | |
| 1770 | + | |
| 1771 | + | |
| 1772 | + | |
| 1773 | + | |
| 1774 | + | |
1767 | 1775 | | |
1768 | 1776 | | |
1769 | 1777 | | |
| |||
1791 | 1799 | | |
1792 | 1800 | | |
1793 | 1801 | | |
1794 | | - | |
1795 | | - | |
1796 | | - | |
| 1802 | + | |
| 1803 | + | |
| 1804 | + | |
| 1805 | + | |
| 1806 | + | |
| 1807 | + | |
| 1808 | + | |
| 1809 | + | |
| 1810 | + | |
| 1811 | + | |
1797 | 1812 | | |
1798 | 1813 | | |
1799 | 1814 | | |
| |||
2052 | 2067 | | |
2053 | 2068 | | |
2054 | 2069 | | |
2055 | | - | |
2056 | | - | |
| 2070 | + | |
| 2071 | + | |
| 2072 | + | |
| 2073 | + | |
| 2074 | + | |
| 2075 | + | |
| 2076 | + | |
| 2077 | + | |
| 2078 | + | |
2057 | 2079 | | |
2058 | 2080 | | |
2059 | 2081 | | |
| |||
2161 | 2183 | | |
2162 | 2184 | | |
2163 | 2185 | | |
2164 | | - | |
| 2186 | + | |
| 2187 | + | |
| 2188 | + | |
| 2189 | + | |
| 2190 | + | |
2165 | 2191 | | |
2166 | 2192 | | |
2167 | 2193 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
| 21 | + | |
20 | 22 | | |
21 | 23 | | |
22 | 24 | | |
| |||
156 | 158 | | |
157 | 159 | | |
158 | 160 | | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
159 | 194 | | |
160 | 195 | | |
161 | 196 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
33 | 39 | | |
34 | 40 | | |
35 | 41 | | |
| |||
0 commit comments