为什么超时发生我会查询我的Cassandra数据库?

时间:2016-01-11 09:38:40

标签: php cassandra

下面是我们的表格描述:

、CREATE KEYSPACE statistics
WITH replication = {
 'class' : 'SimpleStrategy',
 'replication_factor' : 2
};



DROP TABLE IF EXISTS statistics;

CREATE TABLE statistics (
 source text,
 timespan text,
 id text,
 title text,
 thumbnail text,
 url text,
 text text,
 created_at timestamp,
 category text,
 category2 text,
 genre text,
 author text,
 reads int,
 likes int,
 comments int,
 shares int,
 speed int,
 PRIMARY KEY (source, timespan, id)
)WITH CLUSTERING ORDER BY (timespan DESC) AND caching = '{"keys":"ALL", "rows_per_partition":"ALL"}'; 

由Stratio的Cassandra Lucene指数创建指数(https://github.com/Stratio/cassandra-lucene-index

CREATE CUSTOM INDEX statistics_index ON statistics (text)
USING 'com.stratio.cassandra.lucene.Index'
WITH OPTIONS = {
 'refresh_seconds' : '10',
    'schema' : '{
        fields : {
            title    : {type : "text", analyzer : "english"},
   category : {type:"string"},
   category2 : {type:"string"},
   genre : {type:"string"},
   speed  : {type : "integer",sorted : true}
        }
    }'
};

当前端显示使用php查询cassandra数据库时,会出现以下错误消息:

{"message":"Unavailable exception. Error data: array (\n  'consistency' => 2573153,\n  'node' => 1852731252,\n  'replica' => 543253352,\n)","data":{"source":"weibohao","timespan":"1","category":"","genre":"","sort":"speed","sql":"SELECT * FROM statistics WHERE source = 'weibohao' AND timespan = '1' AND text = '{ sort: {fields: [{field: \"speed\", reverse: true}]}}' limit 100"}}

感谢您的回复!

1 个答案:

答案 0 :(得分:3)

“不可用的异常”与超时不同。这意味着无法获得满足所需一致性级别所需的足够复制品。

您的复制因子为2,因此,如果您执行高于一致性级别的任何操作,则需要在查询时启动两个副本,否则您将收到此消息。