protocols/kad: accounting error for background job capacity #4191
Labels
bug
getting-started
Issues that can be tackled if you don't know the internals of libp2p very well
help wanted
Summary
In the kad behaviour poll function the current query capacity is calculated. Then there is a loop over upto
num
possible provider announcement jobs, possibly starting any that are ready. However a soon as one returns pending the loop is exited via break. Then the current query capacity is decreased bynum
, however due to the break the number of queries started may be less thannum
. It seems to me that the capacity should be reduced by the iteration reached in the loop, not the upper bound. (here: https://github.com/libp2p/rust-libp2p/blob/master/protocols/kad/src/behaviour.rs#L2428)Then the code proceeds to iterate over replication jobs, using the reduced capacity as a limit on the number that may be started.
Expected behaviour
jobs_query_capacity
should reflect an accurate capacity for performing replication / publication jobsActual behaviour
jobs_query_capacity
is always lower than the actual capacity so fewer replication / publication jobs can be run than expectedWould you like to work on fixing this bug?
Maybe, although I have no actual Rust skills 😁
The text was updated successfully, but these errors were encountered: