Repository navigation
Commit 0daaa70
feat(sqlite): cap the window cloudsync_payload_chunks prepares
Preparation is unbounded. #75 removed the quadratic term, so a drain is now
linear in the stream, but linear still means a large enough tenant cannot
finish inside the job deadline -- and because nothing is persisted until the
loop reaches is_final, every attempt restarts from chunk 0 and keeps no
progress.
max_window_bytes ends the scan once that many payload bytes have been emitted,
reporting an ordinary complete stream over a smaller window: is_final with the
watermark lowered to the last db_version emitted. The caller checkpoints there
and asks again, so preparation is bounded with no new resumable state and no
protocol change. Unset (the default) is byte-identical to today.
Two conditions are load-bearing. A window may not end mid-value or
mid-db_version: the receive cursor must land on a complete db_version or the
next request skips the unapplied remainder, since it resumes with
db_version > since and no seq. And because that boundary test is what stops
the scan, a db_version larger than the whole budget is still emitted in full,
so a window can never come out empty and stall the drain.
window_capped is an output column, so it does not move the hidden columns a
table-valued call binds positionally; max_window_bytes is declared last, taking
argument 8 and leaving 1..7 as they were.
Also: an explicit NULL for resume_db_version now means "not given", as it
already did for site_id. Callers must pass NULLs to reach a later argument, and
reading one as a resume point of 0 silently restarted the scan at the start of
the window.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>1 parent b75146e commit 0daaa70
2 files changed
Lines changed: 153 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1035 | 1035 | | |
1036 | 1036 | | |
1037 | 1037 | | |
| 1038 | + | |
| 1039 | + | |
| 1040 | + | |
| 1041 | + | |
| 1042 | + | |
| 1043 | + | |
1038 | 1044 | | |
1039 | 1045 | | |
1040 | 1046 | | |
| |||
1048 | 1054 | | |
1049 | 1055 | | |
1050 | 1056 | | |
1051 | | - | |
| 1057 | + | |
| 1058 | + | |
| 1059 | + | |
| 1060 | + | |
| 1061 | + | |
| 1062 | + | |
1052 | 1063 | | |
1053 | 1064 | | |
1054 | 1065 | | |
| |||
1086 | 1097 | | |
1087 | 1098 | | |
1088 | 1099 | | |
1089 | | - | |
1090 | | - | |
1091 | | - | |
| 1100 | + | |
| 1101 | + | |
| 1102 | + | |
1092 | 1103 | | |
1093 | 1104 | | |
1094 | 1105 | | |
| |||
1305 | 1316 | | |
1306 | 1317 | | |
1307 | 1318 | | |
| 1319 | + | |
| 1320 | + | |
| 1321 | + | |
| 1322 | + | |
| 1323 | + | |
| 1324 | + | |
| 1325 | + | |
| 1326 | + | |
| 1327 | + | |
| 1328 | + | |
| 1329 | + | |
| 1330 | + | |
| 1331 | + | |
| 1332 | + | |
| 1333 | + | |
| 1334 | + | |
| 1335 | + | |
| 1336 | + | |
| 1337 | + | |
| 1338 | + | |
| 1339 | + | |
| 1340 | + | |
| 1341 | + | |
| 1342 | + | |
| 1343 | + | |
| 1344 | + | |
1308 | 1345 | | |
1309 | 1346 | | |
1310 | | - | |
| 1347 | + | |
| 1348 | + | |
| 1349 | + | |
| 1350 | + | |
1311 | 1351 | | |
1312 | 1352 | | |
1313 | 1353 | | |
| |||
1353 | 1393 | | |
1354 | 1394 | | |
1355 | 1395 | | |
1356 | | - | |
| 1396 | + | |
| 1397 | + | |
| 1398 | + | |
| 1399 | + | |
| 1400 | + | |
| 1401 | + | |
| 1402 | + | |
| 1403 | + | |
| 1404 | + | |
| 1405 | + | |
1357 | 1406 | | |
1358 | 1407 | | |
| 1408 | + | |
| 1409 | + | |
| 1410 | + | |
| 1411 | + | |
1359 | 1412 | | |
1360 | 1413 | | |
1361 | 1414 | | |
| |||
1445 | 1498 | | |
1446 | 1499 | | |
1447 | 1500 | | |
1448 | | - | |
| 1501 | + | |
| 1502 | + | |
| 1503 | + | |
| 1504 | + | |
| 1505 | + | |
1449 | 1506 | | |
1450 | 1507 | | |
1451 | 1508 | | |
| |||
1466 | 1523 | | |
1467 | 1524 | | |
1468 | 1525 | | |
| 1526 | + | |
1469 | 1527 | | |
1470 | 1528 | | |
1471 | 1529 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
630 | 630 | | |
631 | 631 | | |
632 | 632 | | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
633 | 720 | | |
634 | 721 | | |
635 | 722 | | |
| |||
650 | 737 | | |
651 | 738 | | |
652 | 739 | | |
| 740 | + | |
653 | 741 | | |
654 | 742 | | |
655 | 743 | | |
| |||
0 commit comments