我在删除密钥空间时遇到问题。
有问题的密钥空间有4个与此类似的表:
CREATE KEYSPACE demo WITH replication = {'class': 'SimpleStrategy', 'replication_factor': '1'} AND durable_writes = false;
CREATE TABLE demo.t1 (
t11 int,
t12 timeuuid,
t13 int,
t14 text,
t15 text,
t16 boolean,
t17 boolean,
t18 int,
t19 timeuuid,
t110 text,
PRIMARY KEY (t11, t12)
) WITH CLUSTERING ORDER BY (t13 DESC)
AND bloom_filter_fp_chance = 0.01
AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'}
AND comment = ''
AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'}
AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'}
AND crc_check_chance = 1.0
AND dclocal_read_repair_chance = 0.1
AND default_time_to_live = 0
AND gc_grace_seconds = 864000
AND max_index_interval = 2048
AND memtable_flush_period_in_ms = 0
AND min_index_interval = 128
AND read_repair_chance = 0.0
AND speculative_retry = '99PERCENTILE';
CREATE INDEX t1_idx ON demo.t1 (t14);
CREATE INDEX t1_deleted_idx ON demo.t2 (t15);
当我想使用以下命令删除键空间时:
Session session = cluster.connect();
PreparedStatement prepared = session.prepare("drop keyspace if exists " + schemaName);
BoundStatement bound = prepared.bind();
session.execute(bound);
然后查询超时(或执行时间超过10秒),即使表是空的:
com.datastax.driver.core.exceptions.OperationTimedOutException: [/192.168.0.1:9042] Timed out waiting for server response at com.datastax.driver.core.exceptions.OperationTimedOutException.copy(OperationTimedOutException.java:44) at com.datastax.driver.core.exceptions.OperationTimedOutException.copy(OperationTimedOutException.java:26) at com.datastax.driver.core.DriverThrowables.propagateCause(DriverThrowables.java:37) at com.datastax.driver.core.DefaultResultSetFuture.getUninterruptibly(DefaultResultSetFuture.java:245) at com.datastax.driver.core.AbstractSession.execute(AbstractSession.java:64) at com.datastax.driver.core.AbstractSession.execute(AbstractSession.java:39)
我在多台机器上试过这个,结果是一样的。我正在使用Cassandra 3.9。使用cqlsh也会发生类似的事情。我知道我可以在cassandra.yaml文件中增加读取超时,但是如何让它更快地丢弃呢?另一件事是,如果我连续两次请求,第一个请求超时,第二个请求快速。
答案 0 :(得分:1)
尝试使用增加的超时运行它:
cqlsh --request-timeout = 3600 (以秒为单位,默认为10秒)
驱动程序级别也应该有相同的设置。查看此链接中的超时会话:
http://docs.datastax.com/en/developer/java-driver/3.1/manual/socket_options/
答案 1 :(得分:0)
增加超时只会隐藏问题并且通常是一个坏主意。看看这个答案:https://stackoverflow.com/a/16618888/7413631