我正在尝试使用一个cassandradb邮件数据库,我想过滤我的电子邮件。当我尝试过滤它们时,我得到了一个错误:
ReadFailure: Error from server: code=1300 [Replica(s) failed to execute read] message="Operation failed - received 0 responses and 1 failures" info={'failures': 1, 'received_responses': 0, 'required_responses': 1, 'consistency': 'ONE'}
我试图在/var/log/cassandra/system.log中的日志中了解有关此错误的更多信息:
WARN [ReadStage-2] 2018-09-10 18:23:52,079 AbstractLocalAwareExecutorService.java:167 - Uncaught exception on thread Thread[ReadStage-2,10,main]: {}
java.lang.AssertionError: null
at org.apache.cassandra.db.rows.BTreeRow.getCell(BTreeRow.java:218) ~[apache-cassandra-3.11.2.jar:3.11.2]
at org.apache.cassandra.index.sasi.conf.ColumnIndex.getValueOf(ColumnIndex.java:252) ~[apache-cassandra-3.11.2.jar:3.11.2]
at org.apache.cassandra.index.sasi.plan.Operation.localSatisfiedBy(Operation.java:215) ~[apache-cassandra-3.11.2.jar:3.11.2]
at org.apache.cassandra.index.sasi.plan.Operation.satisfiedBy(Operation.java:145) ~[apache-cassandra-3.11.2.jar:3.11.2]
at org.apache.cassandra.index.sasi.plan.QueryPlan$ResultIterator.computeNext(QueryPlan.java:124) ~[apache-cassandra-3.11.2.jar:3.11.2]
at org.apache.cassandra.index.sasi.plan.QueryPlan$ResultIterator.computeNext(QueryPlan.java:71) ~[apache-cassandra-3.11.2.jar:3.11.2]
at org.apache.cassandra.utils.AbstractIterator.hasNext(AbstractIterator.java:47) ~[apache-cassandra-3.11.2.jar:3.11.2]
at org.apache.cassandra.db.transform.BasePartitions.hasNext(BasePartitions.java:92) ~[apache-cassandra-3.11.2.jar:3.11.2]
at org.apache.cassandra.db.partitions.UnfilteredPartitionIterators$Serializer.serialize(UnfilteredPartitionIterators.java:303) ~[apache-cassandra-3.11.2.jar:3.11.2]
at org.apache.cassandra.db.ReadResponse$LocalDataResponse.build(ReadResponse.java:167) ~[apache-cassandra-3.11.2.jar:3.11.2]
at org.apache.cassandra.db.ReadResponse$LocalDataResponse.<init>(ReadResponse.java:160) ~[apache-cassandra-3.11.2.jar:3.11.2]
at org.apache.cassandra.db.ReadResponse$LocalDataResponse.<init>(ReadResponse.java:156) ~[apache-cassandra-3.11.2.jar:3.11.2]
at org.apache.cassandra.db.ReadResponse.createDataResponse(ReadResponse.java:76) ~[apache-cassandra-3.11.2.jar:3.11.2]
at org.apache.cassandra.db.ReadCommand.createResponse(ReadCommand.java:346) ~[apache-cassandra-3.11.2.jar:3.11.2]
at org.apache.cassandra.service.StorageProxy$LocalReadRunnable.runMayThrow(StorageProxy.java:1886) ~[apache-cassandra-3.11.2.jar:3.11.2]
at org.apache.cassandra.service.StorageProxy$DroppableRunnable.run(StorageProxy.java:2594) ~[apache-cassandra-3.11.2.jar:3.11.2]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) ~[na:1.8.0_171]
at org.apache.cassandra.concurrent.AbstractLocalAwareExecutorService$FutureTask.run(AbstractLocalAwareExecutorService.java:162) ~[apache-cassandra-3.11.2.jar:3.11.2]
at org.apache.cassandra.concurrent.AbstractLocalAwareExecutorService$LocalSessionFutureTask.run(AbstractLocalAwareExecutorService.java:134) [apache-cassandra-3.11.2.jar:3.11.2]
at org.apache.cassandra.concurrent.SEPWorker.run(SEPWorker.java:109) [apache-cassandra-3.11.2.jar:3.11.2]
at java.lang.Thread.run(Thread.java:748) [na:1.8.0_171]
这是我的表格结构:
CREATE TABLE mail__mail (
accountid uuid,
date timestamp,
mailfrom text,
subject text,
size bigint,
id uuid,
attachment set<uuid>,
categories set<uuid>,
content text,
dateadded timestamp,
folderid uuid,
hash text,
isconfidential boolean,
isdeleted boolean,
isimportant boolean,
isseen boolean,
mailcc text,
mailid text,
mailto text,
PRIMARY KEY (accountid, date, id)
) WITH CLUSTERING ORDER BY (date DESC);
CREATE CUSTOM INDEX mailFromIndex ON mail__mail (mailfrom) USING 'org.apache.cassandra.index.sasi.SASIIndex' WITH OPTIONS = {'mode': 'CONTAINS','analyzed': 'true', 'analyzer_class': 'org.apache.cassandra.index.sasi.analyzer.NonTokenizingAnalyzer', 'case_sensitive': 'false'};
CREATE CUSTOM INDEX subjectIndex ON mail__mail (subject) USING 'org.apache.cassandra.index.sasi.SASIIndex' WITH OPTIONS = {'mode': 'CONTAINS','analyzed': 'true', 'analyzer_class': 'org.apache.cassandra.index.sasi.analyzer.NonTokenizingAnalyzer', 'case_sensitive': 'false'};
下面是创建错误的查询:
SELECT * FROM mail__mail WHERE accountid=*UUID* AND folderid=*UUID* AND categories CONTAINS *UUID* AND subject LIKE '%*TEXT*%' LIMIT 50 ALLOW FILTERING;
以下是一些示例数据:
accountid | date | id | attachment | categories | content | dateadded | folderid | hash | isconfidential | isdeleted | isimportant | isseen | mailcc | mailfrom | mailid | mailto | size | subject
-------------------------------------+---------------------------------+--------------------------------------+------------+------------+---------------------+---------------------------------+--------------------------------------+------------------------------------------------------------------+----------------+-----------+-------------+--------+--------+---------------+--------+----------------+-------+---------
00321cc1-efef-41f7-a6d8-3d9e38e3e25f | 2018-09-05 08:52:15.000000+0000 | 738424b0-3e47-4dd8-8785-c1e182f4cc84 | null | null | <p>test</p>\r\n\r\n | 2018-09-11 14:09:07.112000+0000 | 2f64751c-a53f-4364-8538-3498907d1381 | cda1624bb1ce809a6fd2fa8e5ae6a96c8729d9a7485bbba2aacc56dc31d0fc9e | False | False | False | True | | test@test.com | 6522 | test1@test.com | 23481 | test
00321cc1-efef-41f7-a6d8-3d9e38e3e25f | 2018-09-05 08:50:23.000000+0000 | 32cf8b88-ccef-4c36-abbe-ae13800bc499 | null | null | <p>test</p>\r\n\r\n | 2018-09-11 14:09:07.111000+0000 | 2f64751c-a53f-4364-8538-3498907d1381 | dbd23efa7e0aaf9e6174ca06b58e794db70d2980493ebfdd99a499744b79ceca | False | False | False | True | | test@test.com | 6521 | test1@test.com | 2729 | test
提前感谢您的帮助!
1条答案
按热度按时间plicqrtu1#
ALLOW FILTERING
is显式地允许cassandra执行表扫描,但由于性能原因,这并不是一个好主意。如果表中有大量记录,则扫描它可能需要比超时设置允许的时间多得多的时间。解决方案是以不需要查询的方式重新设计表ALLOW FILTERING
. 这些应该只是为了调试的原因。