apache / couchdb-nano

Nano: The official Apache CouchDB library for Node.js
https://www.npmjs.com/package/nano
Apache License 2.0
651 stars 165 forks source link

New nano changeReader stalls on forever growing backoff delay #257

Closed weareu closed 3 years ago

weareu commented 3 years ago

Expected Behavior

When the changeReader encounters a temporary connectivity issue or when timeouts due to CouchDB cluster delays, the back-off code causes the delay timeout to grow very quickly to many hours due to its exponential nature.

Current Behavior

The back-off code tries to prevent this by maxing out on 6000 which should delay every minute. It is using Math.max however which could be the issue as maybe it was intended to use Math.min. A few minutes of successive failures will effectively stall the reader.

Possible Solution

Use Math.min instead of Math.max OR alternatively if the intention is correct to at least wait a minute. Use a max to define a upper bound for the wait time.

Steps to Reproduce (for bugs)

  1. Start an indefinite changeReader listener (batches or not).
  2. Kill your connection to the server.
  3. Reconnect after a minute or so.

Context

Production change listeners are stalling for hours and we could not figure out why. Site restarts every few hours daily on workers responsible was all we could do to alleviate this.

Your Environment