php / php/php-src

Weird behaviour for DNS resolution

Ouverte
#14,245 2 commentaires 2 réactions 0 personnes assignées Voir sur GitHub

Personne n'a encore pris cette issue.

Bug Category: DNS Status: Needs Triage
Langage dominant
C
Étoiles
40.4k
Forks
8.2k
Merge moyen
2 j 15 h
PR mergées (30 j)
103

Description

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

Guide de contribution

Ouvrir le guide de contribution

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Piste de recherche

Commencez dans ext/standard/dns.c et reproduisez le comportement de PHP 8.3 avec un nom d’hôte qui possède un enregistrement A, mais aucun enregistrement AAAA. Suivez la manière dont les réponses A et AAAA sont mises en cache ou invalidées, puis ajoutez ou mettez à jour une couverture ciblée afin qu’un résultat A valide reste en cache lorsque la réponse AAAA est vide.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
c, php
Domaine
backend, networking
Type d'issue
Bug
Difficulté
4/5
Temps estimé
3-5 jours
Activité
Calme
Clarté
À clarifier
Accessibilité débutants
35/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.