To Datastax C#驱动程序工程师:Datastax C#驱动程序3.3.0连接到群集时发生死锁?
C#驱动程序3.3.0在致电Connect()
时死锁。在Windows窗体下面的代码片段将僵局尝试连接:
public void SimpleConnectTest()
{
const string ip = "127.0.0.1";
const string keyspace = "somekeyspace";
QueryOptions queryOptions = new QueryOptions();
queryOptions.SetConsistencyLevel(ConsistencyLevel.One);
Cluster cluster = Cluster.Builder()
.AddContactPoints(ip)
.WithQueryOptions(queryOptions)
.Build();
var cassandraSession = cluster.Connect(keyspace);
Assert.AreNotEqual(null, cassandraSession);
cluster.Dispose();
}
死锁发生在这里:
Cluster.cs ->
private void Init()
{
...
TaskHelper.WaitToComplete(_controlConnection.Init(), initialAbortTimeout);
...
}
我已经在本地机器上的卡桑德拉3.9.0测试此,CQL规范3.4.2。在调用此方法_controlConnection.Init()
一切死锁在这里:
task = Id = 11, Status = WaitingForActivation, Method = "{null}", Result = "{Not yet computed}"
这然后就运行了30000ms,并抛出这样的:
throw new TimeoutException(
"Cluster initialization was aborted after timing out. This mechanism is put in place to" +
" avoid blocking the calling thread forever. This usually caused by a networking issue" +
" between the client driver instance and the cluster.", ex);
在3.2.0运行相同的测试没有这样的问题。任何人都可以测试这个吗?也许这只是发生在我身上。
编辑:
这里是僵局的截图:
这是在控制台应用程序? Web应用程序? Web表单应用程序? –
这发生在Windows窗体应用程序,Windows服务和IIS应用程序上。所有在Windows Server 2012 R2上运行。还在我的本地机器上使用Windows 10对其进行了测试。所有内容均针对.NET Framework 4.5.2编写。 –
从你的解释中,你所遇到的并不是死锁:调用线程永远不会被阻塞(很久以后它会抛出一个异常)。要理解底下发生了什么,应该启用[驱动程序日志记录](http://docs.datastax.com/en/developer/csharp-driver/3.3/faq/#how-can-i-enable-logging-在最驱动程序)。 – jorgebg