Commit 76947fd
[BUGFIX] Ingester: release TSDB appender on early-return paths in Push (#7528)
* [BUGFIX] Ingester: release TSDB appender on early-return paths in Push
Push acquired a TSDB appender at the start of the function and, on early
returns (e.g. out-of-order label set, hard append errors, Commit failure),
could return without calling Commit or Rollback. This leaked TSDB head
series references, mmap'd chunks, and pending appender state, observable
as monotonic growth of cortex_ingester_tsdb_head_active_appenders.
Defer Rollback right after the appender is acquired and skip it on the
success path. `committed` is flipped to true before app.Commit() because
Prometheus closes the appender even on Commit failure (internal
self-rollback on WAL error), so the deferred Rollback must not run
afterwards. The two now-redundant explicit Rollback calls inside the
sample / histogram failure paths are removed and rely on the same defer.
Add a regression test asserting cortex_ingester_tsdb_head_active_appenders
stays at 0 after repeated out-of-order-label-set pushes.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Signed-off-by: Sandy Chen <Yuxuan.Chen@morganstanley.com>
* [BUGFIX] Ingester: modernize for-loop in regression test
Address `make check-modernize` lint failure by using Go 1.22+ `for range N`
syntax instead of `for n := 0; n < numLeakyPushes; n++`.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Signed-off-by: Sandy Chen <Yuxuan.Chen@morganstanley.com>
---------
Signed-off-by: Sandy Chen <Yuxuan.Chen@morganstanley.com>
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 85df243 commit 76947fd
3 files changed
Lines changed: 83 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
| 42 | + | |
42 | 43 | | |
43 | 44 | | |
44 | 45 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1437 | 1437 | | |
1438 | 1438 | | |
1439 | 1439 | | |
| 1440 | + | |
| 1441 | + | |
| 1442 | + | |
| 1443 | + | |
| 1444 | + | |
| 1445 | + | |
| 1446 | + | |
| 1447 | + | |
| 1448 | + | |
| 1449 | + | |
| 1450 | + | |
| 1451 | + | |
| 1452 | + | |
| 1453 | + | |
| 1454 | + | |
| 1455 | + | |
1440 | 1456 | | |
1441 | 1457 | | |
1442 | 1458 | | |
| |||
1505 | 1521 | | |
1506 | 1522 | | |
1507 | 1523 | | |
1508 | | - | |
1509 | | - | |
1510 | | - | |
1511 | | - | |
1512 | | - | |
| 1524 | + | |
| 1525 | + | |
1513 | 1526 | | |
1514 | 1527 | | |
1515 | 1528 | | |
| |||
1560 | 1573 | | |
1561 | 1574 | | |
1562 | 1575 | | |
1563 | | - | |
1564 | | - | |
1565 | | - | |
1566 | | - | |
| 1576 | + | |
| 1577 | + | |
1567 | 1578 | | |
1568 | 1579 | | |
1569 | 1580 | | |
| |||
1626 | 1637 | | |
1627 | 1638 | | |
1628 | 1639 | | |
| 1640 | + | |
| 1641 | + | |
| 1642 | + | |
| 1643 | + | |
1629 | 1644 | | |
1630 | 1645 | | |
1631 | 1646 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2833 | 2833 | | |
2834 | 2834 | | |
2835 | 2835 | | |
| 2836 | + | |
| 2837 | + | |
| 2838 | + | |
| 2839 | + | |
| 2840 | + | |
| 2841 | + | |
| 2842 | + | |
| 2843 | + | |
| 2844 | + | |
| 2845 | + | |
| 2846 | + | |
| 2847 | + | |
| 2848 | + | |
| 2849 | + | |
| 2850 | + | |
| 2851 | + | |
| 2852 | + | |
| 2853 | + | |
| 2854 | + | |
| 2855 | + | |
| 2856 | + | |
| 2857 | + | |
| 2858 | + | |
| 2859 | + | |
| 2860 | + | |
| 2861 | + | |
| 2862 | + | |
| 2863 | + | |
| 2864 | + | |
| 2865 | + | |
| 2866 | + | |
| 2867 | + | |
| 2868 | + | |
| 2869 | + | |
| 2870 | + | |
| 2871 | + | |
| 2872 | + | |
| 2873 | + | |
| 2874 | + | |
| 2875 | + | |
| 2876 | + | |
| 2877 | + | |
| 2878 | + | |
| 2879 | + | |
| 2880 | + | |
| 2881 | + | |
| 2882 | + | |
| 2883 | + | |
| 2884 | + | |
| 2885 | + | |
| 2886 | + | |
| 2887 | + | |
| 2888 | + | |
| 2889 | + | |
| 2890 | + | |
| 2891 | + | |
| 2892 | + | |
| 2893 | + | |
2836 | 2894 | | |
2837 | 2895 | | |
2838 | 2896 | | |
| |||
0 commit comments