diff --git a/bazel/c-ares.patch b/bazel/c-ares.patch index f73964124ddd9..b1848b50986ce 100644 --- a/bazel/c-ares.patch +++ b/bazel/c-ares.patch @@ -31,3 +31,21 @@ index eabd17fc..83bcf06f 100644 if (file_lookup(hquery) == ARES_SUCCESS) { end_hquery(hquery, ARES_SUCCESS); +# Fix reentrant query removal after QID reuse (c-ares PR #1256) +diff --git a/src/lib/ares_process.c b/src/lib/ares_process.c +--- a/src/lib/ares_process.c ++++ b/src/lib/ares_process.c +@@ -1601,7 +1601,12 @@ static void ares_detach_query(ares_query_t *query) + { + /* Remove the query from all the lists in which it is linked */ + ares_query_remove_from_conn(query); +- ares_htable_szvp_remove(query->channel->queries_by_qid, query->qid); ++ /* A callback may queue a new query that reuses this ID. Only remove the ++ * entry if it still points to this query. */ ++ if (ares_htable_szvp_get_direct(query->channel->queries_by_qid, query->qid) == ++ query) { ++ ares_htable_szvp_remove(query->channel->queries_by_qid, query->qid); ++ } + ares_llist_node_destroy(query->node_all_queries); + query->node_all_queries = NULL; + } diff --git a/changelogs/current/bug_fixes/dns_resolver__preserve-reused-cares-qid.rst b/changelogs/current/bug_fixes/dns_resolver__preserve-reused-cares-qid.rst new file mode 100644 index 0000000000000..2df9f113956b7 --- /dev/null +++ b/changelogs/current/bug_fixes/dns_resolver__preserve-reused-cares-qid.rst @@ -0,0 +1 @@ +Fixed the c-ares resolver to preserve a reentrant query when it reuses the completing query's DNS transaction ID. Previously, the old query could remove the new query's ID mapping and permanently stall DNS refresh for the affected cluster.