2017-03-09 220 views
2

我试图插入数据到卡桑德拉。我有1M4整数的列表,我想在一个表与下面的架构中插入:卡桑德拉写超时写作

CREATE TABLE IF NOT EXISTS my_table (
    node_id bigint, 
    screen_name text, 
    centrality float, 
    friend_follower_id bigint, 
    is_friend boolean, 
    is_follower boolean, 
    PRIMARY KEY ((node_id), friend_follower_id)); 

插入数据我做了以下内容:

prepared_statement = session.prepare("INSERT INTO {0} (node_id, screen_name, friend_follower_id, centrality, is_follower) VALUES ({1}, {2}, ?, {3}, true)".format("met_table", author_id, author_username, 0.0) 
execute_concurrent_with_args(session, prepared_statement, zip(followers)) 

的错误,如:

cassandra.WriteTimeout: Error from server: code1100 [Coordinator node timed out waiting for replica nodes' responses] message="Operation timed -out received only 0 responses." info={'consistency': LOCAL_ONE, 'received_response':0, 'required_response':1} 

如何在写入大量数据时避免超时?

回答

3

该错误表示服务器端协调器超时。这受cassandra.yaml设置write_request_timeout_in_ms的管理。你可以尝试提高。

当群集不堪重负并且服务器GC暂停挂载副本时,有时会出现这种情况。但是,在更高的一致性水平上更常见。您还没有说过关于您的群集大小或复制因子的任何信息。你用RF = 3运行吗?

最后,如果您的群集分配无法处理此写入工作负载,可以通过将concurrency参数减少为execute_concurrent_with_args来减轻负载。

+0

我正在使用localhost。我的复制因子设置为2. – mel

+0

我增加了(x10)write_request_timeout,但是我遇到的问题是让我的电脑速度非常慢,我认为这卡住了我的代码。一半数据已被插入,但其他数据未被插入。我计算我想插入的列表的大小,大小约为10MB,是一个正常的Usecase?我应该把它分成小块吗? – mel