我在cassandra环境读取时出现了一条晦涩的错误消息。
如果有人对我调查此错误的看法有任何想法。甚至不确定为什么它具有一致性所有问题,因为当我进入CQLSH会话并设置Consistency All并运行查询时,它很高兴。
消息:一致性读取查询期间的Cassandra超时所有(需要2个副本响应超过3个)
堆栈追踪:
在Cassandra.Tasks.TaskHelper.WaitToComplete(任务任务,Int32超时)
在Cassandra.Session.Execute(IStatement statement)
at MyCode ....:line xxx
C#:
SocketOptions options = new SocketOptions();
options.SetConnectTimeoutMillis(30000);
options.SetReadTimeoutMillis(5000);
options.SetDefunctReadTimeoutThreshold(int.MaxValue);
options.SetTcpNoDelay(true);
Cluster = Cluster.Builder()
.AddContactPoints(seeds)
.WithCredentials(username, password)
.WithQueryOptions(new QueryOptions().SetConsistencyLevel(ConsistencyLevel.LocalQuorum))
.WithPoolingOptions(new PoolingOptions().SetHeartBeatInterval(10000).SetMaxConnectionsPerHost(HostDistance.Local, 2).SetCoreConnectionsPerHost(HostDistance.Local, 2))
.WithRetryPolicy(DowngradingConsistencyRetryPolicy.Instance)
.WithQueryTimeout(60000)
.WithReconnectionPolicy(new ConstantReconnectionPolicy(1000))
.WithSpeculativeExecutionPolicy(new ConstantSpeculativeExecutionPolicy(500, 2))
.WithLoadBalancingPolicy(new TokenAwarePolicy(new DCAwareRoundRobinPolicy()))
.WithSocketOptions(options)
.Build();
Session = Cluster.Connect();
在引发异常时调用Connection.Session.Cluster.Configuration.QueryOptions.GetConsistencyLevel(),该值仍为本地仲裁。
查询:
3个分区键中的3个。
2个聚类列中的1个。
C#:
var cqlStatement = "SELECT * FROM data.poc WHERE pk1 = ? and pk2 = ? and pk3 = ? and ck1 = ?;"
List<object> cqlParams = new List<object>();
cqlParams.add("somestring");
cqlParams.add(500);
cqlParams.add(36000);
cqlParams.add(false);
Cassandra.PreparedStatement prepared = Session.Prepare(cqlStatement);
Cassandra.RowSet results =
Connection.Session.Execute(prepared.Bind(cqlParams.ToArray()));