Skip to content

Commit

Permalink
fix(eventstore): Use more correct start date for eventstore (#67070)
Browse files Browse the repository at this point in the history
Clickhouse behaves oddly when the normal epoch is used for dates:


ClickHouse/ClickHouse#9335 (comment)

This was working before by coincedence: an obsolete piece of code (query
splitters) in Snuba was clamping the date to a non-epoch value. When the
query
splitters were removed, this started breaking.

Instead of simply asking for "all time" use a date that aligns with how
our
data is actually stored.

This is also not a new issue, see
#30912
  • Loading branch information
evanh committed Mar 15, 2024
1 parent 7c337d0 commit 91c0646
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
4 changes: 3 additions & 1 deletion src/sentry/eventstore/snuba/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,9 @@ def get_adjacent_event_ids(self, event, filter):
prev_filter = deepcopy(filter)
prev_filter.conditions = prev_filter.conditions or []
prev_filter.conditions.extend(get_before_event_condition(event))
prev_filter.start = datetime.fromtimestamp(0)

# We only store 90 days of data, add a few extra days just in case
prev_filter.start = event.datetime - timedelta(days=100)
# the previous event can have the same timestamp, add 1 second
# to the end condition since it uses a less than condition
prev_filter.end = event.datetime + timedelta(seconds=1)
Expand Down
3 changes: 0 additions & 3 deletions tests/sentry/eventstore/snuba/test_backend.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
from unittest import mock

import pytest

from sentry.eventstore.base import Filter
from sentry.eventstore.models import Event
from sentry.eventstore.snuba.backend import SnubaEventStorage
Expand Down Expand Up @@ -221,7 +219,6 @@ def test_get_event_beyond_retention(self):
event = self.eventstore.get_event_by_id(self.project2.id, "d" * 32)
assert event is None

@pytest.mark.xfail(reason="fails in Snuba CI")
def test_get_adjacent_event_ids(self):
event = self.eventstore.get_event_by_id(self.project2.id, "b" * 32)

Expand Down

0 comments on commit 91c0646

Please sign in to comment.