ethersphere / bee

Bee is a Swarm client implemented in Go. It’s the basic building block for the Swarm network: a private; decentralized; and self-sustaining network for permissionless publishing and access to your (application) data.
https://www.ethswarm.org
BSD 3-Clause "New" or "Revised" License
1.44k stars 338 forks source link

Cannot disable pushsync multiplexer #4681

Closed ldeffenb closed 1 month ago

ldeffenb commented 1 month ago

Context

2.1.0-rc2 (and earlier versions)

Summary

I tried disabling the pushsync multiplexer by setting maxMultiplexForwards to zero, but that completely disabled push syncing.

Expected behavior

maxMultiplexForwards should be able to be set to zero to disable the pushsync multiplexer.

Actual behavior

Setting the value to zero completely disables push syncing because the retryC channel has zero buffer space. Violates the "Principle of least astonishment" (https://en.wikipedia.org/wiki/Principle_of_least_astonishment).

Steps to reproduce

Set maxMultiplexForwards to zero and watch how push syncs never happen because the initial retry() invocation doesn't have any room to queue into retryC and therefore the pushsync retry loop never activates. https://github.com/ethersphere/bee/blob/92de2855d39c94cc1b7d78955c81463e1edcc72f/pkg/pushsync/pushsync.go#L52

Possible solution

Update the following line to ensure that at least one entry exists in the channel. https://github.com/ethersphere/bee/blob/92de2855d39c94cc1b7d78955c81463e1edcc72f/pkg/pushsync/pushsync.go#L342 should read: retryC := make(chan struct{}, max(1,parallelForwards))