Skip to content

feat(discover): Split Discover Dataset task - #76201

Merged
shruthilayaj merged 28 commits into
masterfrom
shruthi/feat/discover-dataset-split-task
Aug 29, 2024
Merged

shruthilayaj merged 28 commits into
masterfrom
shruthi/feat/discover-dataset-split-task

Conversation

@shruthilayaj

@shruthilayaj shruthilayaj commented Aug 14, 2024 •

Copy link
Copy Markdown
Member

Task that will split Discover saved queries
This PR just introduces the task (doesn't actually run it)

@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label Aug 14, 2024
@codecov

codecov Bot commented Aug 14, 2024 •

Copy link
Copy Markdown

Codecov Report

Attention: Patch coverage is 78.84615% with 55 lines in your changes missing coverage. Please review.

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/sentry/discover/dataset_split.py 84.00% 14 Missing and 14 partials ⚠️
src/sentry/tasks/split_discover_query_dataset.py 67.46% 21 Missing and 6 partials ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           master   #76201       +/-   ##
===========================================
+ Coverage   57.31%   78.18%   +20.86%     
===========================================
  Files        6898     6906        +8     
  Lines      306775   307046      +271     
  Branches    50296    50324       +28     
===========================================
+ Hits       175829   240059    +64230     
+ Misses     126160    60577    -65583     
- Partials     4786     6410     +1624     

Comment on lines +2566 to +2576
register(
"discover.saved-query-dataset-split.enable",
default=False,
flags=FLAG_PRIORITIZE_DISK | FLAG_AUTOMATOR_MODIFIABLE,
)
register(
"discover.saved-query-dataset-split.organization-allowlist",
type=Sequence,
default=[],
flags=FLAG_PRIORITIZE_DISK | FLAG_AUTOMATOR_MODIFIABLE,
)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is there a benefit to us setting them as options instead of Flagpole? iirc Flagpole works for ST now

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The first one is a kill switch - just bypasses the whole task or forces us to break out of the task, this should just be an on/off not tied to anything so we can quickly shut it down in case it causes an incident

The second one, I kinda went back and forth on a little, my thinking was to initially just limit the queryset to the allowlisted orgs https://github.com/getsentry/sentry/pull/76201/files#diff-179f670f3f1385148441a5abb704eec14d23b90a6fbace8ca071996985c17815R54
instead of looping through the whole queryset and checking individual orgs. Then once we're done testing, just remove that option and run the task on dataset selector enabled orgs. I don't have strong opinions on this one though

Comment thread src/sentry/discover/dataset_split.py Resolved
Comment thread src/sentry/discover/dataset_split.py Resolved
@shruthilayaj
shruthilayaj marked this pull request as ready for review August 16, 2024 21:48
@shruthilayaj
shruthilayaj requested a review from a team as a code owner August 16, 2024 21:48
@shruthilayaj
shruthilayaj requested a review from wmak August 16, 2024 21:48

@wmak wmak left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Mostly small comments and nits, lgtm otherwise

One thing to consider would be to unit-test the functions in dataset_split, but they're e2e tested which is fine

Comment thread src/sentry/discover/dataset_split.py Outdated
]


def save_split_decision_for_query(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Lets prefix these with _ and add a comment explaining that these functions should only be used for the split migration so other people in the org don't try to use 'em

Comment thread src/sentry/options/defaults.py Outdated
flags=FLAG_PRIORITIZE_DISK | FLAG_AUTOMATOR_MODIFIABLE,
)
register(
"discover.saved-query-dataset-split.organization-allowlist",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit: can we call this

Suggested change
"discover.saved-query-dataset-split.organization-allowlist",
"discover.saved-query-dataset-split.organization-id-allowlist",


SLEEP_FOR = 5 * 60 # 5 minutes
MAX_NOOP_ATTEMPTS = 10
RATE_LIMIT_CACHE: MutableMapping[str | int, int] = LRUCache(maxsize=1000)

@wmak wmak Aug 27, 2024 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Do we have a rough estimate on the runtime per org yet? (could check snuba admin if not). Just want to be sure that 1000 is big enough

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Ran a redash query actually, we don't have enough distinct org ids with discover saved queries that we need cache with an upper limit - I just made it a regular dict

@narsaynorath narsaynorath left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good to me, good job on this. It's very thorough and it looks like you've distilled the queries down to their most minimal forms for querying to evaluate the split

Comment thread src/sentry/discover/dataset_split.py Outdated
return False


def check_top_level_conditions_match_dataset(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The terminology you used here, top_level_conditions, are there conditions that are not top level?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

We basically don't bother checking nested conditions like (foo AND (bar OR baz)) will only check foo condition

@shruthilayaj

Copy link
Copy Markdown
Member Author

One thing to consider would be to unit-test the functions in dataset_split, but they're e2e tested which is fine

I added some unit tests for the logic that splits datasets without querying snuba!
3824091#diff-1f53d05795f5e5a6afb8672dc304c7a1ca0403f167e76d62d659cb00e09b5e8dR544

@shruthilayaj
shruthilayaj merged commit 55d5792 into master Aug 29, 2024
@shruthilayaj
shruthilayaj deleted the shruthi/feat/discover-dataset-split-task branch August 29, 2024 15:35
@github-actions github-actions Bot locked and limited conversation to collaborators Sep 14, 2024

This branch was successfully deployed

1 active deployment
Preview — 0061f81c Deployed Aug 28, 2024 by vercel[bot]
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Scope: Backend Automatically applied to PRs that change backend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants