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

The Sum and Product BinaryOperators should prevent number overflows #19

Open
p013570 opened this issue May 11, 2017 · 2 comments
Open
Labels
enhancement Improvement to existing functionality/feature
Milestone

Comments

@p013570
Copy link
Member

p013570 commented May 11, 2017

Before computing integer1+integer2 we should check that the maximum will not be more than Integer.MAX_VALUE.

See below for suggested solution.

@p013570 p013570 added the question Specific query about part of the codebase label May 11, 2017
@p013570 p013570 mentioned this issue May 11, 2017
@t616178
Copy link
Contributor

t616178 commented Jul 20, 2017

I think it would be a good idea to protect against this. There are a number of different solutions we could try:

I don't think the second option is great, but I'd be a bit worried about causing issues in applications by throwing exceptions every time there is an overflow error - something which could easily happen when calculating products of Integers?

@n3101 n3101 added this to the v2_backlog milestone Aug 25, 2021
@n3101 n3101 changed the title Should the Sum and Product BinaryOperators check for number overflows? The Sum and Product BinaryOperators should prevent number overflows Aug 30, 2022
@n3101 n3101 removed the question Specific query about part of the codebase label Aug 30, 2022
@n3101
Copy link

n3101 commented Aug 30, 2022

In a discussion offline @d21211122 said:
"Basically, there's a balance to be struck. We have to choose the least worst option... currently, we would have a failed aggregator (which isn't very nice when it's being run as part of an accumulo iterator.. i'm not quite sure how it would deal with it, but at the very least, I don't see how we'd ever get the affected records back out of the table, and at the very worse, I think it would screw up the whole compaction).

I'm not sure I like either of (the options above). Changing the data type might screw with anything that relies on the schema.

We could implement a simple 'fix', which would set the value to the MAX value if it goes above it, and it remains at MAX forever. It won't fail, but it will give incorrect data back and there won't be any indication that that is the case. We could log it, but the user won't see it."

Given the potential severity of the failure outlined above, we should consider d21211122's fix. Capping the value should be logged, so that at least there is a record of the event somewhere.

@GCHQDeveloper314 GCHQDeveloper314 added the enhancement Improvement to existing functionality/feature label Jul 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improvement to existing functionality/feature
Projects
None yet
Development

No branches or pull requests

4 participants