簡體   English   中英

Cassandra由於TTL過期而計時

[英]Cassandra Timing out because of TTL expiration

我正在使用DataStax社區v 2.1.2-1(AMI v 2.5)預裝默認設置+增加讀取時間到10秒這里是問題

 create table simplenotification_ttl (
               user_id varchar, 
               real_time timestamp,
               insert_time timeuuid,
               read boolean,
               msg varchar, PRIMARY KEY (user_id, real_time, insert_time));

插入查詢:

insert into simplenotification_ttl (user_id, real_time, insert_time, read) 
  values ('test_3',14401440123, now(),false) using TTL 800;

對於相同的'test_3',我插入了33,000個元組。 [ 24,000個元組不會發生這個問題 ]

漸漸地,我明白了

cqlsh:notificationstore> select count(*)  from simplenotification_ttl where user_id = 'test_3'; 

 count
-------
 15681

(1 rows)

cqlsh:notificationstore> select count(*)  from simplenotification_ttl where user_id = 'test_3'; 

 count
-------
 12737

(1 rows)

cqlsh:notificationstore> select count(*)  from simplenotification_ttl where user_id = 'test_3'; 
**errors={}, last_host=127.0.0.1**

我甚至在不同的桌子上進行了多次實驗。 一旦發生這種情況,即使我插入相同的user_id並使用限制1進行檢索。它會超時。

我要求TTL正常工作,即在推測時間后給出計數0。 如何解決這個問題? 謝謝

[我的其他節點相關設置使用m3.large和2個節點EC2Snitch]

您遇到了一個問題,其中墓碑(已刪除的值)的數量超過了閾值,然后超時。

如果打開跟蹤然后嘗試select語句,則可以看到此信息,例如:

cqlsh> tracing on;
cqlsh> select count(*) from test.simple;

 activity                                                                        | timestamp    | source       | source_elapsed
---------------------------------------------------------------------------------+--------------+--------------+----------------
...snip...
 Scanned over 100000 tombstones; query aborted (see tombstone_failure_threshold) | 23:36:59,324 |  172.31.0.85 |         123932
                                                    Scanned 1 rows and matched 1 | 23:36:59,325 |  172.31.0.85 |         124575
                           Timed out; received 0 of 1 responses for range 2 of 4 | 23:37:09,200 | 172.31.13.33 |       10002216

你有點碰到Cassandra的反模式,數據在被刪除之前只存儲了很短的時間。 有一些選項可以更好地處理這個問題,包括在需要時重新訪問您的數據模型。 以下是一些資源:

對於您的示例問題,我嘗試將gc_grace_seconds設置降低到300(5分鍾)。 這導致墓碑比默認的10天更頻繁地清理,但根據您的應用程序可能適合或不適合。 閱讀刪除的含義,您可以根據應用需要進行調整。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM