Commit ca62681
committed
fix index.clear()
Before: the `.clear()` algorithm is wrong:
1. Suppose they are 2200 documents. The first 500 are deleted:
0 1000 2000
| | |
xxxxx-----------------
| |
| index + limit
index
2. There are now 1700 documents, and the next pagination query wrongly
skips the first 500 documents, and remove from 500 to 1000:
0 1000
| |
-----xxxxx-------
| |
| index + limit
index
3. There are now 1200 documents, and the next pagination query wrongly
skips the first 1000 documents, and remove from 1000 to 1200:
0 1000
| |
----------xx
=> Only 1200 of the 2200 documents are remove, and 1000 documents remain.
After: 500 documents are deleted in loop until there is nothing to
delete (with a security condition on the initial documents number, in
case of concurrent insertions).1 parent 242bee2 commit ca62681
1 file changed
+26
-11
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
| |||
717 | 718 | | |
718 | 719 | | |
719 | 720 | | |
720 | | - | |
| 721 | + | |
721 | 722 | | |
722 | 723 | | |
723 | 724 | | |
| |||
745 | 746 | | |
746 | 747 | | |
747 | 748 | | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
748 | 754 | | |
| 755 | + | |
749 | 756 | | |
750 | | - | |
751 | | - | |
752 | | - | |
753 | | - | |
754 | | - | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
755 | 761 | | |
| 762 | + | |
| 763 | + | |
756 | 764 | | |
757 | 765 | | |
758 | 766 | | |
| |||
1615 | 1623 | | |
1616 | 1624 | | |
1617 | 1625 | | |
| 1626 | + | |
| 1627 | + | |
| 1628 | + | |
| 1629 | + | |
| 1630 | + | |
1618 | 1631 | | |
| 1632 | + | |
1619 | 1633 | | |
1620 | | - | |
1621 | | - | |
1622 | | - | |
1623 | | - | |
1624 | | - | |
| 1634 | + | |
| 1635 | + | |
| 1636 | + | |
| 1637 | + | |
1625 | 1638 | | |
| 1639 | + | |
| 1640 | + | |
1626 | 1641 | | |
1627 | 1642 | | |
1628 | 1643 | | |
| |||
0 commit comments