Skip to content

Conversation

trillville
Copy link

Fixes an integer out of range error in the times_seen column of sentry_groupedmessage.

This error occurs when client SDKs send events with extremely low sample_rate values. The Sentry backend calculates times_seen by inverting this rate (1 / sample_rate), which can result in a value exceeding PostgreSQL's integer field limit (2,147,483,647).

This PR introduces a validation function in Relay (validate_sample_rate_for_times_seen) that caps the effective sample_rate if its inverse would lead to an integer overflow. This validation is applied during event normalization and to Dynamic Sampling Contexts.

This prevents database errors by ensuring times_seen values remain within PostgreSQL's integer bounds, with warnings logged when a sample rate is capped.

Legal Boilerplate

Look, I get it. The entity doing business as "Sentry" was incorporated in the State of Delaware in 2015 as Functional Software, Inc. and is gonna need some rights from me in order to utilize my contributions in this here PR. So here's the deal: I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Sentry can use, modify, copy, and redistribute my contributions, under Sentry's choice of terms.


Open in Cursor Open in Web

Add validation for client sample rates to cap values that would cause overflow in the backend.

Co-authored-by: tillman.elser <[email protected]>
Copy link

cursor bot commented Sep 26, 2025

Cursor Agent can help with this pull request. Just @cursor in comments and I'll start working on changes in this branch.
Learn more about Cursor Agents

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.

2 participants