【问题标题】:Cassandra datastax driver times out on a too big a queryCassandra datastax 驱动程序在查询过大时超时
【发布时间】:2016-09-21 23:11:17
【问题描述】:

这个查询很好,但如果我更改取回数据的时间量,我会收到以下错误(超过 200,000 行)。我不确定问题是查询还是填充/重新采样操作。我的集群中只有一台机器。

rsltES = session.execute( """SELECT * FROM tickdata.timeseries  
    WHERE 
    curve = 0 
    AND symbol = 1000
    AND time > '2016-05-23T08:00:00-0400'
    AND time < '2016-05-25T19:00:00-0400'
    order by time
    allow filtering;""")

dfes = dfes.set_index(['time'])
dfes.index.tz_localize('US/Eastern')
df_ohlcES = dfes.resample('5Min').ohlc()
df_ohlcES = df_ohlcES.ffill()
df_ohlcES['DateTime'] = np.arange(len(df_ohlcES))

# Move the DateTime Column to the Front
colsES = df_ohlcES.columns
colsES = colsES[-1:] | colsES[:-1]
df_ohlcES = df_ohlcES[colsES]

如果查询返回的数据过多,则查询超时。有没有办法增加超时时间?

Traceback (most recent call last):
  File "pandascas.py", line 36, in <module>
    allow filtering;""")
  File "cassandra/cluster.py", line 1647, in cassandra.cluster.Session.execute (cassandra/cluster.c:28041)
  File "cassandra/cluster.py", line 3243, in cassandra.cluster.ResponseFuture.result (cassandra/cluster.c:61954)
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, 'required_responses': 1, 'consistency': 'LOCAL_ONE'}

【问题讨论】:

    标签: python pandas datastax cassandra-2.0


    【解决方案1】:

    这是在cassandra.yaml 中设置的服务器端读取超时。这需要服务器设置并重新启动。

    如果您确实获得了太多行,您还可以尝试减少 fetch_size 以使请求的页面更小。

    您可能还想了解您的工作负载是否经常被覆盖——这种情况会导致许多墓碑导致读取缓慢。您可以做的一项经验检查是提高超时时间并打开 tracing 以查看需要这么长时间。

    【讨论】:

      【解决方案2】:

      数据库超时默认为 2 秒。您可以做的不是增加此超时时间,而是使用 fetchSize 并以块的形式获取结果。请记住,允许过滤是一种不好的坏习惯,它基本上是一个全表搜索,会触及集群中的所有节点,这可能是导致您超时的原因,即使您没有查询数百万行。

      【讨论】:

        猜你喜欢
        • 2014-03-16
        • 2013-07-14
        • 2020-11-23
        • 2017-08-17
        • 2016-02-27
        • 2017-01-20
        • 2014-03-31
        • 2016-10-06
        • 1970-01-01
        相关资源
        最近更新 更多