Commit e15ca5f
committed
resource: error out if reserve_additional_memory is too large
there is chance that configured reserve_additional_memory exceeds
total_memory. as both of them can be configured at runtime either
programtically or using command line option or config file. so
- if the former is greater than the latter, we could have integer
underflow, in that case `needed_memory` could be a very large number,
and `needed_memory > available_memory` is likely to be evaluated
to true, and the thrown error still sends the right message. but
this hurts the readability.
- if reserve_additional_memory is a very large number, like
size_t(-1), we will also have integer underflow, but `needed_memory`
would be `c.total_memory + 1`, which still can be greater than
`available_memory`, and no exceptions are thrown. this is not
expected. we should have warn user that the reserve_additional_memory
is too large.
in this change, before calculating the `needed_memory`,
`c.total_memory` is compared with `c.reserve_additional_memory`,
exception is thrown if the former is less than the latter.
Signed-off-by: Kefu Chai <kefu.chai@scylladb.com>1 parent 5a6ecdf commit e15ca5f
1 file changed
Lines changed: 3 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
223 | 223 | | |
224 | 224 | | |
225 | 225 | | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
226 | 229 | | |
227 | 230 | | |
228 | 231 | | |
| |||
0 commit comments