Weird behaviour for DNS resolution
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- C
- Sterne
- 40.4k
- Forks
- 8.1k
- Ø Merge
- 2 T. 13 Std.
- Gemergte PRs (30 T.)
- 96
Beschreibung
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) :
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.
PHP Version
8.3
Operating System
No response
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne in ext/standard/dns.c und reproduziere das Verhalten von PHP 8.3 mit einem Hostnamen, der einen A-Record, aber keinen AAAA-Record hat. Verfolge, wie die A- und AAAA-Antworten zwischengespeichert oder invalidiert werden, und füge anschließend eine gezielte Abdeckung hinzu oder aktualisiere sie, sodass ein gültiges A-Ergebnis zwischengespeichert bleibt, wenn die AAAA-Antwort leer ist.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- c, php
- Bereich
- backend, networking
- Issue-Typ
- Bug
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Ruhig
- Klarheit
- Muss geklärt werden
- Anfängerfreundlichkeit
- 35/100