简体   繁体   English

如果并行调用,Mono Dns操作将挂起

[英]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. 我在Mono上的Dns类遇到了一个高度可重现的问题,从C#调用:如果我从多台计算机(例如,在群集上)进行多次调用,或多或少并发(例如启动批处理程序时) ,某些随机数的电话会挂起。

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. Mono Dns类很可能没有正确地超时并重新发出请求:DNS使用基于UDP的RPC协议,并且由于UDP不可靠,如果十个数据包同时全部命中某个DNS服务器,或者类似的情况,一个丢失,将不会收到任何答复。

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? 这是我的问题:有谁知道一种干净的方法来中断Mono上C#对Dns.GetHostName或Dns.GetHostInfo的调用,以便在发生这种情况时,可以强制重新发出请求?

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. 因此,问题在于,确实,Mono的库中存在一些与DNS对话的错误,该错误自2005年左右开始记录,但尚未修复。 There is a second version of the DNS library that some people claim works better. DNS库的第二个版本有人认为可以更好地工作。

For my own purposes, it turned out that I could eliminate almost all DNS calls from my code. 出于我自己的目的,事实证明我可以从代码中消除几乎所有DNS调用。 After all, hangs in DNS code triggered by lost packets in the DNS are a pretty scary thing to live with. 毕竟,由DNS中丢失数据包触发的DNS代码挂起是一件很可怕的事情。

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. 我认为这是一个很好的示例代码,将UDP通信视为可靠,并且因为它在重负载下非常可靠,所以存在一个缠绵的bug,根本无法修复。 But very easily triggered by simply putting the Mono DNS under heavy load. 但是,只需将Mono DNS置于繁重的负载下,即可轻松触发。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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