Bad argument in arithmetic expression in `Finch.HTTP2.Pool`
We are getting a "bad argument in arithmetic expression" error in this line. It seems that either max_backoff, base_backoff, or factor have a non-numeric value.
When would that happen? Could it be related to our configuration?
That's possible. Could you please share your config so we could see?
Thanks @sneako, we create the child with the following pools option:
%{
:default => [size: 10],
"https://fly.storage.tigris.dev" => [
conn_opts: [log: true],
size: 500,
count: 1,
protocols: [:http2]
]
}
Bumping this one :)
This happens here: https://github.com/sneako/finch/blob/f857ad514411f8ae7383bb431827769612493434/lib/finch/http2/pool.ex#L677
defp backoff(base_backoff, max_backoff, failure_count) do
factor = :math.pow(2, failure_count)
max_sleep = trunc(min(max_backoff, base_backoff * factor))
:rand.uniform(max_sleep)
end
Can be observed when failure count reaches 1024
iex(1)> :math.pow(2,1023)
8.98846567431158e307
iex(2)> :math.pow(2,1024)
** (ArithmeticError) bad argument in arithmetic expression
(stdlib 6.2.2.2) :math.pow(2, 1024)
iex:2: (file)
In general this happens with ephemeral backends, especially if you are using IP's with headless services in Kubernetes.
Not sure if this helps @pepicrft but I am looking at similar issues.
Edit: It actually happens when the failure_count reaches 1015 with a base_backoff of 500, but the cause remains the same, unbounded calculations with :math.pow.
Bumping above, any insights to when/how to fix this?