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 an issue wheras a -1 breaker limit was interpreted wrongly #13096

Merged
merged 1 commit into from Oct 6, 2022

Conversation

seut
Copy link
Member

@seut seut commented Oct 4, 2022

Summary of the changes / Why this improves CrateDB

A -1 limit on a breaker should not result in breaking but just accounting. This was not taken into account at the breakers getFree() method. It will return Long.MAX_VALUE in this case now.

Additionally if will return 0 if the limit is set to 0 which indicates that the breaker should refuce any data according to the related breaker implementation.
See also ChildMemoryCircuitBreaker.addEstimateBytesAndMaybeBreak().

Checklist

  • Added an entry in CHANGES.txt for user facing changes
  • Updated documentation & sql_features table for user facing changes
  • Touched code is covered by tests
  • CLA is signed
  • This does not contain breaking changes, or if it does:
    • It is released within a major release
    • It is recorded in CHANGES.txt
    • It was marked as deprecated in an earlier release if possible
    • You've thought about the consequences and other components are adapted
      (E.g. AdminUI)

@seut seut requested a review from mfussenegger October 4, 2022 10:28
Copy link
Contributor

@BaurzhanSakhariev BaurzhanSakhariev left a comment

Choose a reason for hiding this comment

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

Let's merge this into 5.0?

Copy link
Member

@mfussenegger mfussenegger left a comment

Choose a reason for hiding this comment

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

Left a question, if that's already handled lgtm

Comment on lines +71 to +77
if (memoryBytesLimit == -1) {
freeSupplier = () -> Long.MAX_VALUE;
} else if (memoryBytesLimit == 0) {
freeSupplier = () -> 0L;
} else {
freeSupplier = () -> getLimit() - getUsed();
}
Copy link
Member

Choose a reason for hiding this comment

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

Could it also be set to other negative values, or is that forbidden already?

Copy link
Member Author

Choose a reason for hiding this comment

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

A `-1` limit on a breaker should not result in breaking but just
accounting. This was not taken into account at the breakers
`getFree()` method. It will return Long.MAX_VALUE in this case now.

Additionally if will return `0` if the limit is set to `0` which
indicates that the breaker should refuce any data according to
the related breaker implementation.
See also ChildMemoryCircuitBreaker.addEstimateBytesAndMaybeBreak().
@seut seut added the ready-to-merge Let Mergify merge the PR once approved and checks pass label Oct 6, 2022
@mergify mergify bot merged commit 28f50d4 into master Oct 6, 2022
@mergify mergify bot deleted the s/fix-breaker-get-free branch October 6, 2022 08:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready-to-merge Let Mergify merge the PR once approved and checks pass v/5.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants