Commit 9b739c6
committed
feat(migration): refuse batch plans with overlapping index prefixes
Two RediSearch indexes whose key prefixes overlap (one is a literal
string-prefix of the other, matching FT.CREATE PREFIX semantics) cover
the same Redis keyspace. Running a batch quantization migration over
them re-reads vectors that an earlier index in the batch has already
quantized, producing garbage bytes and corrupting data.
Reject these batches at plan time so the operator must split the
migration into disjoint groups before any vectors are touched.
- utils: add normalize_prefixes and find_overlapping_index_groups, and
align build_scan_match_patterns with FT.CREATE PREFIX semantics
(literal prefix + glob, no injected key separator) so the scan
pattern matches the same keyspace the planner reasons about.
- planner: same scan-pattern fix in MigrationPlanner; bump the SCAN
COUNT hint while we're touching the loop.
- batch_planner: collect prefixes during applicability checks and
raise ValueError listing the overlapping (index, index, [pairs])
before create_batch_plan returns.
- tests/unit: TestBatchMigrationPlannerOverlapDetection covers
identical, nested, multi-prefix, and disjoint cases plus the
applicable-only filtering rule.
- tests/integration: TestBatchMigrationOverlapDetectionIntegration
exercises the same paths against a real Redis with FT.CREATE'd
indexes.1 parent 7352af0 commit 9b739c6
5 files changed
Lines changed: 409 additions & 13 deletions
File tree
- redisvl/migration
- tests
- integration
- unit
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | | - | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
17 | 22 | | |
18 | 23 | | |
19 | 24 | | |
| |||
83 | 88 | | |
84 | 89 | | |
85 | 90 | | |
| 91 | + | |
86 | 92 | | |
87 | 93 | | |
88 | 94 | | |
89 | | - | |
| 95 | + | |
90 | 96 | | |
91 | 97 | | |
92 | 98 | | |
93 | 99 | | |
94 | 100 | | |
95 | 101 | | |
96 | 102 | | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
97 | 112 | | |
98 | 113 | | |
99 | 114 | | |
| |||
156 | 171 | | |
157 | 172 | | |
158 | 173 | | |
159 | | - | |
| 174 | + | |
160 | 175 | | |
161 | 176 | | |
162 | 177 | | |
163 | | - | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
164 | 181 | | |
165 | 182 | | |
166 | 183 | | |
167 | 184 | | |
168 | 185 | | |
| 186 | + | |
169 | 187 | | |
170 | 188 | | |
171 | 189 | | |
| |||
189 | 207 | | |
190 | 208 | | |
191 | 209 | | |
| 210 | + | |
192 | 211 | | |
193 | 212 | | |
194 | 213 | | |
| |||
212 | 231 | | |
213 | 232 | | |
214 | 233 | | |
| 234 | + | |
215 | 235 | | |
216 | 236 | | |
217 | 237 | | |
| |||
227 | 247 | | |
228 | 248 | | |
229 | 249 | | |
| 250 | + | |
230 | 251 | | |
231 | 252 | | |
232 | 253 | | |
| |||
247 | 268 | | |
248 | 269 | | |
249 | 270 | | |
| 271 | + | |
250 | 272 | | |
251 | 273 | | |
252 | 274 | | |
| |||
268 | 290 | | |
269 | 291 | | |
270 | 292 | | |
| 293 | + | |
271 | 294 | | |
272 | 295 | | |
273 | 296 | | |
| |||
279 | 302 | | |
280 | 303 | | |
281 | 304 | | |
282 | | - | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
283 | 310 | | |
284 | 311 | | |
285 | 312 | | |
| |||
298 | 325 | | |
299 | 326 | | |
300 | 327 | | |
| 328 | + | |
301 | 329 | | |
302 | 330 | | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
303 | 358 | | |
304 | 359 | | |
305 | 360 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
639 | 639 | | |
640 | 640 | | |
641 | 641 | | |
642 | | - | |
643 | | - | |
644 | 642 | | |
645 | | - | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
646 | 648 | | |
647 | 649 | | |
648 | 650 | | |
649 | 651 | | |
650 | 652 | | |
651 | | - | |
| 653 | + | |
652 | 654 | | |
653 | 655 | | |
654 | 656 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
100 | 100 | | |
101 | 101 | | |
102 | 102 | | |
103 | | - | |
104 | | - | |
105 | | - | |
106 | | - | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
107 | 108 | | |
108 | 109 | | |
109 | 110 | | |
| |||
340 | 341 | | |
341 | 342 | | |
342 | 343 | | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
343 | 397 | | |
344 | 398 | | |
345 | 399 | | |
| |||
0 commit comments