Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: catch potential overflow #25123

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

LorrensP-2158466
Copy link
Contributor

Closes #25041

Describe your proposed changes here.
Do the multiplication with checked_mul and return Option<i64> instead of i64.
Also, 2 places use this function with Option::map, so I replaced those with Option::and_then

  • I've read the contributing section of the project README.
  • Signed CLA (if not already signed).

@LorrensP-2158466 LorrensP-2158466 marked this pull request as draft July 2, 2024 16:25
Copy link
Contributor

@hiltontj hiltontj left a comment

Choose a reason for hiding this comment

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

I think panicking on overflow is not as good as returning an error, but is better than what is being done with these changes. What will happen with these changes, in the event of an overflow, is the ingest time will be used as the timestamp for the written line. That is not likely the same as whatever timestamp was provided by the user, so the resulting writes would have unexpected timestamps.

If anything, the overflow should be checked in a previous validation step that is fallible, so an error can be returned to reject those lines, and provide an error message - indicating that there is likely a mismatch in the specified precision and the time value provided.

@LorrensP-2158466
Copy link
Contributor Author

Yeah, when I pushed, I went over it again, and the changes didn't feel right to me, but I couldn't find a direct reason or how to solve it.
Thanks for the explanation! I'll try to find a better way of checking the overflow in the way that you mentioned.

Quick question with no urgency: the merge conflicts in Cargo.lock, how should I resolve them?

@hiltontj
Copy link
Contributor

hiltontj commented Jul 2, 2024

Quick question with no urgency: the merge conflicts in Cargo.lock, how should I resolve them?

If you can merge back the latest changes from the main branch on this repository, and resolve conflicts, that would probably do the trick. So, sync your fork, then locally you can git merge main from your current branch. Hopefully, the merge conflicts aren't a pain to deal with, but sometimes you have to go through and manually resolve them.

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.

Potential overflow panic
2 participants