简体   繁体   中英

Mono Dns operations hang if called in parallel

I've run into a highly reproducible problem with the Dns class on Mono, called from C#: if I do multiple calls from multiple machines (on a cluster, for example), more or less concurrently (like when a batch program starts up), some random number of the calls hang.

It seems pretty likely that the Mono Dns class isn't properly timing out and reissuing requests: DNS uses a UDP-based RPC protocol and since UDP isn't reliable, if ten packets hit a DNS server all the same time or something and one is lost, no reply will be forthcoming.

Here's my question: Does anyone know of a clean way to interrupt a call to Dns.GetHostName or Dns.GetHostInfo, from C# on Mono, so that when this does happen, I can force the request to be reissued?

By now I guess I should answer my own question. So the deal is that indeed, there is some kind of bug in Mono's library for talking to the DNS, documented since around 2005 but not yet fixed. There is a second version of the DNS library that some people claim works better.

For my own purposes, it turned out that I could eliminate almost all DNS calls from my code. After all, hangs in DNS code triggered by lost packets in the DNS are a pretty scary thing to live with.

I think this is a good example of code that treats UDP communication as if it was reliable, and because it is pretty reliable except under heavy load, has a lingering bug that simply never gets fixed. But very easily triggered by simply putting the Mono DNS under heavy load.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM