Skip to content

Conversation

@MeredithAnya
Copy link
Member

FIXES SNUBA-9X1

Although this wont be an issue once all the clusters are upgraded https://github.com/getsentry/ops/pull/17973

@MeredithAnya MeredithAnya requested a review from a team as a code owner November 13, 2025 20:31
Comment on lines 101 to 103
lw_sync = get_int_config("lightweight_deletes_sync")
if lw_sync:
query_settings.set_clickhouse_settings({"lightweight_deletes_sync": lw_sync})
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: The change to get_int_config removes the default, causing lightweight_deletes_sync to be None and not set, leading to a KeyError in test_clickhouse_settings.
Severity: CRITICAL | Confidence: 1.00

🔍 Detailed Analysis

The get_int_config("lightweight_deletes_sync") call in the new code returns None when the config is not explicitly set, unlike the old code which defaulted to 2. This causes the if lw_sync: condition to evaluate to False, preventing query_settings.set_clickhouse_settings() from being called. Consequently, the test_clickhouse_settings assertion assert clickhouse_settings["lightweight_deletes_sync"] == 2 fails with a KeyError because the lightweight_deletes_sync key is missing from clickhouse_settings.

💡 Suggested Fix

Update test_clickhouse_settings to align with the new behavior where lightweight_deletes_sync is only set if explicitly configured, or reintroduce a default value to get_int_config if the old behavior is intended.

🤖 Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location: snuba/lw_deletions/strategy.py#L101-L103

Potential issue: The `get_int_config("lightweight_deletes_sync")` call in the new code
returns `None` when the config is not explicitly set, unlike the old code which
defaulted to `2`. This causes the `if lw_sync:` condition to evaluate to `False`,
preventing `query_settings.set_clickhouse_settings()` from being called. Consequently,
the `test_clickhouse_settings` assertion `assert
clickhouse_settings["lightweight_deletes_sync"] == 2` fails with a `KeyError` because
the `lightweight_deletes_sync` key is missing from `clickhouse_settings`.

Did we get this right? 👍 / 👎 to inform future reviews.

Reference_id: 2665648

@codecov
Copy link

codecov bot commented Nov 13, 2025

❌ 1 Tests Failed:

Tests completed Failed Passed Skipped
699 1 698 7
View the top 1 failed test(s) by shortest run time
tests.lw_deletions.test_lw_deletions::test_clickhouse_settings
Stack Traces | 0.021s run time
Traceback (most recent call last):
  File "/.venv/lib/python3.11........./site-packages/_pytest/runner.py", line 341, in from_call
    result: TResult | None = func()
                             ^^^^^^
  File "/.venv/lib/python3.11........./site-packages/_pytest/runner.py", line 242, in <lambda>
    lambda: runtest_hook(item=item, **kwds), when=when, reraise=reraise
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/.venv/lib/python3.11....../site-packages/pluggy/_hooks.py", line 513, in __call__
    return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/.venv/lib/python3.11....../site-packages/pluggy/_manager.py", line 120, in _hookexec
    return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/.venv/lib/python3.11.........................../site-packages/pluggy/_callers.py", line 182, in _multicall
    return outcome.get_result()
           ^^^^^^^^^^^^^^^^^^^^
  File "/.venv/lib/python3.11.../site-packages/pluggy/_result.py", line 100, in get_result
    raise exc.with_traceback(exc.__traceback__)
  File "/.venv/lib/python3.11.........................../site-packages/pluggy/_callers.py", line 167, in _multicall
    teardown.throw(outcome._exception)
  File "/.venv/lib/python3.11....../site-packages/_pytest/threadexception.py", line 92, in pytest_runtest_call
    yield from thread_exception_runtest_hook()
  File "/.venv/lib/python3.11....../site-packages/_pytest/threadexception.py", line 68, in thread_exception_runtest_hook
    yield
  File "/.venv/lib/python3.11.........................../site-packages/pluggy/_callers.py", line 167, in _multicall
    teardown.throw(outcome._exception)
  File "/.venv/lib/python3.11....../site-packages/_pytest/unraisableexception.py", line 95, in pytest_runtest_call
    yield from unraisable_exception_runtest_hook()
  File "/.venv/lib/python3.11....../site-packages/_pytest/unraisableexception.py", line 70, in unraisable_exception_runtest_hook
    yield
  File "/.venv/lib/python3.11.........................../site-packages/pluggy/_callers.py", line 167, in _multicall
    teardown.throw(outcome._exception)
  File "/.venv/lib/python3.11....../site-packages/_pytest/logging.py", line 846, in pytest_runtest_call
    yield from self._runtest_for(item, "call")
  File "/.venv/lib/python3.11....../site-packages/_pytest/logging.py", line 829, in _runtest_for
    yield
  File "/.venv/lib/python3.11.........................../site-packages/pluggy/_callers.py", line 167, in _multicall
    teardown.throw(outcome._exception)
  File "/.venv/lib/python3.11.../site-packages/_pytest/capture.py", line 880, in pytest_runtest_call
    return (yield)
            ^^^^^
  File "/.venv/lib/python3.11.........................../site-packages/pluggy/_callers.py", line 167, in _multicall
    teardown.throw(outcome._exception)
  File "/.venv/lib/python3.11.../site-packages/_pytest/skipping.py", line 257, in pytest_runtest_call
    return (yield)
            ^^^^^
  File "/.venv/lib/python3.11.........................../site-packages/pluggy/_callers.py", line 103, in _multicall
    res = hook_impl.function(*args)
          ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/.venv/lib/python3.11........./site-packages/_pytest/runner.py", line 174, in pytest_runtest_call
    item.runtest()
  File "/.venv/lib/python3.11....../site-packages/_pytest/python.py", line 1627, in runtest
    self.ihook.pytest_pyfunc_call(pyfuncitem=self)
  File "/.venv/lib/python3.11....../site-packages/pluggy/_hooks.py", line 513, in __call__
    return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/.venv/lib/python3.11....../site-packages/pluggy/_manager.py", line 120, in _hookexec
    return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/.venv/lib/python3.11.........................../site-packages/pluggy/_callers.py", line 139, in _multicall
    raise exception.with_traceback(exception.__traceback__)
  File "/.venv/lib/python3.11.........................../site-packages/pluggy/_callers.py", line 103, in _multicall
    res = hook_impl.function(*args)
          ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/.venv/lib/python3.11....../site-packages/_pytest/python.py", line 159, in pytest_pyfunc_call
    result = testfunction(**testargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^
  File ".../local/lib/python3.11/unittest/mock.py", line 1378, in patched
    return func(*newargs, **newkeywargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".../tests/lw_deletions/test_lw_deletions.py", line 115, in test_clickhouse_settings
    assert clickhouse_settings["lightweight_deletes_sync"] == 2
KeyError: 'lightweight_deletes_sync'

To view more test analytics, go to the Test Analytics Dashboard
📋 Got 3 mins? Take this short survey to help us improve Test Analytics.

@MeredithAnya MeredithAnya enabled auto-merge (squash) November 13, 2025 20:43
@MeredithAnya MeredithAnya merged commit bde13e8 into master Nov 13, 2025
33 checks passed
@MeredithAnya MeredithAnya deleted the meredith/fix-delete-11-13 branch November 13, 2025 21:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants