Commit 934ec04
committed
Mirror::createDocuments: pre-filter existing ids + unify skip/non-skip paths
Addresses Greptile #3084293974. The captureOnNext-based forwarding
was structurally broken: SQL adapters return the full input batch from
createDocuments regardless of what INSERT IGNORE actually inserted, so
onNext fired for every doc including skipped duplicates. captureOnNext
then forwarded the caller's would-be values to destination, diverging
destination from source whenever source had a pre-existing row the
caller tried to re-insert.
Fix: pre-filter against source before the insert to identify which
input ids already exist, then forward only the genuinely-new docs to
destination. A source-skipped duplicate is a no-op (no user write
happened), so nothing should propagate. This matches Greptile's
semantics: destination.dup.isEmpty() after skipping a duplicate.
While the logic was touched, the skip and non-skip paths (which shared
eligibility check, upgrade check, clone loop, destination write, and
after-filter loop) are unified into a single flow with $this->
skipDuplicates branches only at the points where behavior actually
differs:
- source call: wrapped in source->skipDuplicates when active
- $toForward: filter out pre-existing ids when active
- destination call: wrapped in destination->skipDuplicates when active
Non-skip hot path pays zero new closure allocations; the pre-filter
block is gated behind if ($this->skipDuplicates) and short-circuits
to an empty $existingIds map.
Net: -46 lines in createDocuments (~170 → ~95), same test coverage,
Greptile's assertion now holds.1 parent 3c85013 commit 934ec04
2 files changed
Lines changed: 52 additions & 98 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
601 | 601 | | |
602 | 602 | | |
603 | 603 | | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
604 | 608 | | |
605 | | - | |
606 | | - | |
607 | | - | |
608 | | - | |
609 | | - | |
610 | | - | |
611 | | - | |
612 | | - | |
613 | | - | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
614 | 613 | | |
615 | | - | |
616 | | - | |
617 | | - | |
618 | | - | |
619 | | - | |
620 | | - | |
621 | | - | |
622 | | - | |
623 | | - | |
624 | | - | |
625 | | - | |
626 | | - | |
627 | | - | |
628 | | - | |
629 | | - | |
630 | | - | |
631 | | - | |
632 | | - | |
633 | | - | |
634 | | - | |
635 | | - | |
636 | | - | |
637 | | - | |
638 | | - | |
639 | | - | |
640 | | - | |
641 | | - | |
| 614 | + | |
| 615 | + | |
642 | 616 | | |
643 | 617 | | |
644 | 618 | | |
645 | 619 | | |
646 | 620 | | |
647 | | - | |
648 | | - | |
649 | | - | |
650 | | - | |
651 | | - | |
652 | | - | |
653 | | - | |
654 | | - | |
655 | | - | |
656 | | - | |
657 | | - | |
658 | | - | |
659 | | - | |
| 621 | + | |
| 622 | + | |
660 | 623 | | |
661 | | - | |
662 | | - | |
663 | | - | |
664 | | - | |
665 | | - | |
666 | | - | |
667 | | - | |
668 | | - | |
669 | | - | |
670 | | - | |
671 | | - | |
672 | | - | |
673 | | - | |
674 | | - | |
675 | | - | |
676 | | - | |
677 | | - | |
678 | | - | |
679 | | - | |
680 | | - | |
681 | | - | |
682 | | - | |
683 | | - | |
684 | 624 | | |
685 | | - | |
686 | | - | |
687 | 625 | | |
688 | 626 | | |
689 | | - | |
690 | | - | |
691 | | - | |
692 | | - | |
693 | | - | |
694 | | - | |
695 | | - | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
696 | 632 | | |
697 | 633 | | |
698 | 634 | | |
| |||
706 | 642 | | |
707 | 643 | | |
708 | 644 | | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
709 | 658 | | |
710 | 659 | | |
711 | | - | |
712 | | - | |
| 660 | + | |
713 | 661 | | |
714 | | - | |
715 | 662 | | |
716 | 663 | | |
717 | 664 | | |
| |||
720 | 667 | | |
721 | 668 | | |
722 | 669 | | |
723 | | - | |
724 | 670 | | |
725 | 671 | | |
726 | 672 | | |
727 | | - | |
728 | | - | |
729 | | - | |
730 | | - | |
731 | | - | |
732 | | - | |
733 | | - | |
734 | | - | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
735 | 689 | | |
736 | 690 | | |
737 | 691 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
378 | 378 | | |
379 | 379 | | |
380 | 380 | | |
381 | | - | |
382 | | - | |
383 | | - | |
384 | | - | |
385 | | - | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
386 | 386 | | |
387 | 387 | | |
388 | 388 | | |
| |||
0 commit comments