Commit a0d54c6
fix(compactor): make DeleteLocalSyncFiles tests deterministic (pin ring tokens, drive compaction manually)
TestCompactor_DeleteLocalSyncFiles and its partition twin relied on
timer-driven compaction cycles and on the random per-instance ring tokens
drawn at startup. With 2 compactors x 512 random tokens and only 10 fixed
users there is a measured ~0.103% (~1-in-960 per run) chance that the
second compactor owns zero of the users. In such runs every c2 cycle
completes without ever creating a meta-sync directory, so the condition
polled since #7567 (CompactionRunsCompleted >= 2 && len(dirs) > 0) is
permanently false and the test burns the entire 30s budget: the exact
32.8s arm64 CI failure of #7608, and the true root cause of #7565
(#7567's "transient ring-view skew" was a misdiagnosis - no timeout can
fix a permanently false condition).
Restore the manual-drive structure the test had when introduced in #3851
(removed by #6510) and pin the ownership split, identically in both twins:
- CompactionInterval = 10m: timers are out of the picture; the test
drives compaction cycles itself.
- Pin per-instance ring tokens via ShardingRing.TokensFilePath (new
pinnedTokens helper): a guard token fnv32a(user)+1 for alternating
users makes compactor-1 own user-1,3,5,7,9 and compactor-2 own
user-2,4,6,8,10 deterministically, since the integer interval (h, h+1)
is empty and ring lookup picks the first token strictly greater than
the user hash.
- Replace the timed CompactionRunsCompleted polls with direct
compactUsers() calls on both compactors, gated by one poll waiting
until BOTH compactors' ring views see two healthy ACTIVE instances.
- Assert exact ownership counts (numUsers/2 each) instead of
NotZero/NotEqual, so any silent un-pinning fails loudly.
- Tolerate (only) context.Canceled from StopAndAwaitTerminated in the
test cleanup: with a 10m interval the compactor is usually still in its
initial jittered wait when stopped, and running() returns ctx.Err()
there since #6510.
Supersedes #7567's poll-based approach.
Fixes #7608
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Signed-off-by: Sandy Chen <Yuxuan.Chen@morganstanley.com>1 parent 74185ef commit a0d54c6
3 files changed
Lines changed: 127 additions & 34 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
| 60 | + | |
60 | 61 | | |
61 | 62 | | |
62 | 63 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
| |||
1588 | 1589 | | |
1589 | 1590 | | |
1590 | 1591 | | |
| 1592 | + | |
| 1593 | + | |
| 1594 | + | |
| 1595 | + | |
| 1596 | + | |
| 1597 | + | |
| 1598 | + | |
| 1599 | + | |
| 1600 | + | |
| 1601 | + | |
1591 | 1602 | | |
1592 | 1603 | | |
1593 | 1604 | | |
1594 | | - | |
| 1605 | + | |
| 1606 | + | |
| 1607 | + | |
| 1608 | + | |
| 1609 | + | |
| 1610 | + | |
| 1611 | + | |
| 1612 | + | |
1595 | 1613 | | |
1596 | 1614 | | |
1597 | 1615 | | |
| |||
1610 | 1628 | | |
1611 | 1629 | | |
1612 | 1630 | | |
1613 | | - | |
1614 | | - | |
1615 | | - | |
1616 | | - | |
| 1631 | + | |
| 1632 | + | |
| 1633 | + | |
| 1634 | + | |
1617 | 1635 | | |
1618 | 1636 | | |
1619 | 1637 | | |
1620 | 1638 | | |
1621 | 1639 | | |
1622 | 1640 | | |
1623 | | - | |
| 1641 | + | |
1624 | 1642 | | |
1625 | | - | |
1626 | | - | |
1627 | | - | |
1628 | | - | |
1629 | | - | |
1630 | | - | |
1631 | | - | |
1632 | | - | |
1633 | | - | |
| 1643 | + | |
| 1644 | + | |
| 1645 | + | |
| 1646 | + | |
| 1647 | + | |
| 1648 | + | |
| 1649 | + | |
| 1650 | + | |
| 1651 | + | |
| 1652 | + | |
| 1653 | + | |
| 1654 | + | |
| 1655 | + | |
| 1656 | + | |
| 1657 | + | |
| 1658 | + | |
1634 | 1659 | | |
1635 | 1660 | | |
| 1661 | + | |
| 1662 | + | |
| 1663 | + | |
| 1664 | + | |
1636 | 1665 | | |
1637 | 1666 | | |
| 1667 | + | |
1638 | 1668 | | |
1639 | 1669 | | |
1640 | 1670 | | |
1641 | 1671 | | |
1642 | 1672 | | |
1643 | | - | |
1644 | | - | |
| 1673 | + | |
| 1674 | + | |
| 1675 | + | |
1645 | 1676 | | |
1646 | 1677 | | |
1647 | 1678 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
10 | 11 | | |
| 12 | + | |
11 | 13 | | |
12 | 14 | | |
13 | 15 | | |
| |||
1779 | 1781 | | |
1780 | 1782 | | |
1781 | 1783 | | |
| 1784 | + | |
| 1785 | + | |
| 1786 | + | |
| 1787 | + | |
| 1788 | + | |
| 1789 | + | |
| 1790 | + | |
| 1791 | + | |
| 1792 | + | |
| 1793 | + | |
| 1794 | + | |
| 1795 | + | |
| 1796 | + | |
| 1797 | + | |
| 1798 | + | |
| 1799 | + | |
| 1800 | + | |
| 1801 | + | |
| 1802 | + | |
| 1803 | + | |
| 1804 | + | |
| 1805 | + | |
| 1806 | + | |
| 1807 | + | |
| 1808 | + | |
| 1809 | + | |
| 1810 | + | |
| 1811 | + | |
| 1812 | + | |
1782 | 1813 | | |
1783 | 1814 | | |
1784 | 1815 | | |
| |||
1812 | 1843 | | |
1813 | 1844 | | |
1814 | 1845 | | |
| 1846 | + | |
| 1847 | + | |
| 1848 | + | |
| 1849 | + | |
| 1850 | + | |
| 1851 | + | |
| 1852 | + | |
| 1853 | + | |
| 1854 | + | |
| 1855 | + | |
1815 | 1856 | | |
1816 | 1857 | | |
1817 | 1858 | | |
1818 | | - | |
| 1859 | + | |
| 1860 | + | |
| 1861 | + | |
| 1862 | + | |
| 1863 | + | |
| 1864 | + | |
| 1865 | + | |
| 1866 | + | |
1819 | 1867 | | |
1820 | 1868 | | |
1821 | 1869 | | |
| |||
1834 | 1882 | | |
1835 | 1883 | | |
1836 | 1884 | | |
1837 | | - | |
1838 | | - | |
1839 | | - | |
1840 | | - | |
| 1885 | + | |
| 1886 | + | |
| 1887 | + | |
| 1888 | + | |
1841 | 1889 | | |
1842 | 1890 | | |
1843 | 1891 | | |
1844 | 1892 | | |
1845 | 1893 | | |
1846 | 1894 | | |
1847 | | - | |
| 1895 | + | |
1848 | 1896 | | |
1849 | | - | |
1850 | | - | |
1851 | | - | |
1852 | | - | |
1853 | | - | |
1854 | | - | |
1855 | | - | |
1856 | | - | |
1857 | | - | |
| 1897 | + | |
| 1898 | + | |
| 1899 | + | |
| 1900 | + | |
| 1901 | + | |
| 1902 | + | |
| 1903 | + | |
| 1904 | + | |
| 1905 | + | |
| 1906 | + | |
| 1907 | + | |
| 1908 | + | |
| 1909 | + | |
| 1910 | + | |
| 1911 | + | |
| 1912 | + | |
1858 | 1913 | | |
1859 | 1914 | | |
| 1915 | + | |
| 1916 | + | |
| 1917 | + | |
| 1918 | + | |
1860 | 1919 | | |
1861 | 1920 | | |
| 1921 | + | |
1862 | 1922 | | |
1863 | 1923 | | |
1864 | 1924 | | |
1865 | 1925 | | |
1866 | 1926 | | |
1867 | | - | |
1868 | | - | |
| 1927 | + | |
| 1928 | + | |
| 1929 | + | |
1869 | 1930 | | |
1870 | 1931 | | |
1871 | 1932 | | |
| |||
0 commit comments