Retry logic does not handle unresponsive connections well

Aperta
#1,510 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
35/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
node.js, redis, typescript
Ambito
backend, databases

Direzione di ricerca

Traccia i punti di ingresso on_connect(), initialize_retry_vars(), on_ready(), send_offline_queue() e init_retry_vars() menzionati nel report. Riproduci lo scenario in modalità disconnessione con la configurazione di toxiproxy descritta, quindi verifica che i tentativi di retry non vengano reimpostati prematuramente e che i comandi accodati vengano mantenuti fino alla conferma di una connessione autenticata e funzionante.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Issue

I was doing experiments of putting Redis behind a toxiproxy service in kubernetes for integration-test automation of network connectivity errors and server-behavior errors and noticed a few things. In this particular setup when the disconnect-mode testing was active, the redis-client was able to tcp-connect to a forwarding proxy, but would get then get disconnected a few milliseconds after it sent data, with no responses. I noticed this caused problems in two ways in the driver:

  1. The on_connect() logic would call this.initialize_retry_vars(), causing the attempt count seen in the retryStrategy handler to be perpetually stuck at 1.

  2. The use of this.send_offline_queue() in the on_ready() would assume it had a healthy & authenticated connection. At that point, the driver thinks it had run 'auth' and 'select', when actually the 'auth' command had actually failed, and the invocation of this.send_offline_queue() would dequeue and lose all the off-line queued commands on the first failed reconnect.

It seems to me like the code needs two changes to handle this scenario:

  1. The on_ready() should validate it has a healthy connection by making sure a 'ping' command is sent and gets a reply before it tries to send the offline queue commands. Perhaps this could be conditioned with a pingOnConnect connect-option.

  2. The clearing of attempts & re-initialization in init_retry_vars should only happen after all the off-line queue has been sent.

I ended up working around this issue by changing our test-environment to not provide the faux-connection when the redis was in 'disconnect mode' testing. That said, this seems like something that might occur in the future with various HA load-balancers in front of Redis, so I wanted to get this discussed with the code owners and get their agreement on the solutions above before working on a PR.


Environment
  • Node.js Version: 12.16.1
  • Redis Version: redis-10.5.4
  • Platform: Linux (container on MacOS docker)

  • node-redis version: '3.0.2'

Lingua principale
TypeScript
Stelle
17.6k
Fork
2k
Merge medio
1g 22h
PR unite (30g)
62

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di redis/node-redis

Tutte le issue di redis/node-redis

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.