Algorithm change had bug where ets:select return
value was incorrectly assumed to be the object key
and not the entire object causing the following
delete attempt based on a matchspec and the key to fail.
This meant that ets was not updated to reflect the completed
requests on each connection and causing exaustion of pipelines
event though connections were idle. Functional test added which
demonstrated the problem.
In prior commit, missed switch of matchspec to work
with deletes, fixed here.
Added retry logic for race conditions around lb and
conn both trying to update same record at the same time.
If more than max is experienced, just let it go, things
will probably be ok.
Big commit. Switched algorithm to one which will favor
the connection with the smallest pipeline first
(deciding ties by timestamp of last finished request,
and then by pid as ultimate tie breaker).
Note: this also drastically changes the internal
representation of the connection in ets and is dependent
on specific order of operations when changing key values
to limit risk of race conditions between loadbalancer
and a given connection.
Also removed connection reporting of start of request
as this was no longer necessary since the load balancer
tees up the entry into ets with a 1.
Difference between speculative and "real" size was no
longer material to the algorithm. Used macro to enforce
consistent usage of ceiling for pipeline.
HTTP connection process now manages both scenarios
requiring cleaning up of the load balancer's ets table;
instead of this being owned by both the conn and lb.
Moved all interactions with ets table tracking
connections to API functions on ibrowse_lb,
to reduce knowledge of ets table and its structure.
Also fixed "bug" where ceiling for pipelining
threshold was different than the set value for increment;
made them the same.
Tracking size in http connection process state
was unnecessary as it wasn't queried for logic
or obvious reporting and ets table should have
right (within 1) value already.
Verified that all code paths using saved table
identifier from state are guarded either by a
check for undefined or a call to maybe_create_ets,
so the table should always be there when it
is needed without creating before real use.
Prior version was "2". New functional tests suite
was not being picked up by local rebar, but was
execute with my local which is version "2.5.2"
which targets the same version of Erlang/OTP
as iBrowse (R16).