php / php/php-src

Weird behaviour for DNS resolution

Aperta
#14,245 2 commenti 2 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Bug Category: DNS Status: Needs Triage
Lingua principale
C
Stelle
40.4k
Fork
8.2k
Merge medio
2g 13h
PR unite (30g)
96

Descrizione

Description

I have look on the internet and see very little talk about this so it's possible that my php is wrongly configure but I have failed to find a directive related to this.

The following code:

Not sure where the code is located, my C understanding is pretty weak and I'm an ops guy.
I think it's around here : https://github.com/php/php-src/blob/master/ext/standard/dns.c

What I see :

When a php process does a dns query for both A and AAAA type, if A is valid but AAAA is empty, both records are not stored in cache and therefor the next request will trigger a dns query for both type again.
It seems like the empty AAAA response triggers an invalidation in the cache for both A and AAAA record. This behaviour floods the network needlessly.
I have notice this behaviour both on VMs or on containers, and from a wide range of php versions (5.6 to 8.3) or OS versions (Debian 9/10/11/12, Ubuntu 16/18/20/22 or Alpine 3.18/3.19).
I can provide this graph to illustrate better what I'm saying (Yellow and Green line are AAAA and A type) :
Screenshot 2024-05-15 at 14-47-35 CoreDNS - Kubernetes - Dashboards - Grafana

What I would expect :

In my opinion, once a A record have been successfully retrieved, it should be stored in cache and the AAAA should not invalidate it. And maybe once the A record expires it should try again both resolution (A and AAAA).

I have tested successfully to disable ipv6 in kernel for VMs and it drastically reduces the number of DNS query sent by applications (see graph below) and looks like the A response is stored in cache. This is a possible solution for VMs but complicated one in a Kubernetes environment.

Screenshot 2024-05-15 at 14-47-27 Unbound - System - Dashboards - Grafana

PHP Version

8.3

Operating System

No response

Guida per i contributori

Apri la guida per i contributori

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.

Direzione di ricerca

Inizia in ext/standard/dns.c e riproduci il comportamento di PHP 8.3 con un nome host che ha un record A ma nessun record AAAA. Traccia come vengono memorizzate nella cache o invalidate le risposte A e AAAA, quindi aggiungi o aggiorna una copertura mirata in modo che un risultato A valido rimanga nella cache quando la risposta AAAA è vuota.

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

Valutazione

Stack tecnologico
c, php
Ambito
backend, networking
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Tranquilla
Chiarezza
Da chiarire
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.