2014-10-09 55 views
0

我需要讀取表中的所有行(超過一百萬)。我已閱讀關於分頁(http://www.datastax.com/dev/blog/datastax-python-driver-2-0-released) - 沒有多大幫助。 的代碼相當直截了當:Python 2.6 Cassandra 2.0.1 ReadTimeout

... 
retry = RetryPolicy() 
retry.RETRY = 10 
cluster = Cluster(
[ ... ], 
reconnection_policy=ConstantReconnectionPolicy(5.0, 100), 
auth_provider=auth_provider, 
load_balancing_policy=RoundRobinPolicy(), 
default_retry_policy=retry, 
port=9042) 
session = cluster.connect("test") 
session.default_timeout = 9999 
session.default_fetch_size = 1000 

... 
... 

uname_stmt = SimpleStatement(q, fetch_size=100) 
uname_stmt.consistency_level = ConsistencyLevel.ONE 

for row in session.execute(uname_stmt): 
    ... 

基本上後約5分鐘左右(可以是1分鐘或者它可以是10)的最後一個for循環觸發此錯誤:

Traceback (most recent call last): 
File "test.py", line 67, in <module> 
for row in session.execute(uname_stmt): 
File "/usr/lib/python2.6/site-packages/cassandra/cluster.py", line 2939, in next 
result = self.response_future.result(self.timeout) 
File "/usr/lib/python2.6/site-packages/cassandra/cluster.py", line 2771, in result 
raise self._final_exception 
cassandra.ReadTimeout: code=1200 [Coordinator node timed out waiting for replica nodes' responses] message="Operation timed out - received only 0 responses." info={'received_responses': 0, 'data_retrieved': False, 'required_responses': 1, 'consistency': 1} 

任何幫助會很棒! 謝謝!

回答

0

這可能是因爲卡桑德拉試圖重組所有的SSTables。

這就是爲什麼讀取操作在許多SSTable上發生並且超時。

Cassandra使用壓縮管理磁盤上SSTables的累積。

嘗試使用緊湊的命令可能會有所幫助。

nodetool緊湊

+0

感謝您的回覆,我已經試過了,沒有幫助:( 我還安裝了最新的卡桑德拉 - 同樣的問題。 – Pavel 2014-11-03 15:55:51