默认情况下使用 uuid 时,Cassandra TimeUUID 泛滥文件描述符 [英] Cassandra TimeUUID flood file descriptor when use uuid in default
问题描述
我有 Cassandra 模型
I have Cassandra model as
import uuid
from cassandra.cqlengine import columns
from cassandra.cqlengine.models import Model
class MyModel(Model):
...
...
created_at = columns.TimeUUID(primary_key=True,
clustering_order='DESC',
default=uuid.uuid1)
...
...
最近应用程序达到了uuid1 创建未关闭文件 - 达到文件描述符限制.我试图找到解决方案,但似乎我认为哪些选项可能不起作用
Recentrly app hit the uuid1 creation doesn't close files - hits file descriptor limit. I try to find the solution, but seems what options I think might be not work
- 用
uuid4
替换默认的uuid1
,但是TimeUUID
需要时间部分,只有uuid1
提供 - 在检查
uuid1
和uuid_from_time
,两者看起来一样,所以也不解决问题.
- Replace
uuid1
in default withuuid4
, butTimeUUID
need time part in it, and onlyuuid1
provide that. - Relace
uuid1
withcassandra.util.uuid_from_time(time.time())
, when check the code for bothuuid1
anduuid_from_time
, both are looks same, so that also not solve the problem.
最后一个选项是用 Timestamp
类型替换 TimeUUID
,但是这个 created_at
列是 primary_key
和 clustering_order
,所以不知道我能不能做到.
Last option is to replace TimeUUID
with Timestamp
type, but this created_at
column is primary_key
and clustering_order
, so dont know I can do that or not.
我的列族已经有 1,000,000 多条数据,所以我不能丢掉它们.
My column family has already 1,000,000+ data, so I cant just drop them.
我也想知道,用TimeUUID
代替timestamp
有什么好处?
I also want to know, what is the advantage of using TimeUUID
instead of timestamp
?
推荐答案
您确定遇到了您链接的 libuuid
问题吗?您的代码片段显示了标准库 uuid
,它可能没有这个问题.您的程序中是否可能存在不同的文件描述符泄漏?
Are you certain you're hitting the libuuid
issue you linked? Your code snippet shows the standard library uuid
, which probably doesn't have that issue. Is it possible there's a different file descriptor leak in your program?
如果是libuuid
,最简单的方法是使用标准库实现.如果速度是您的主要关注点,您可能会考虑构建不同版本的 libuuid
以与 python-libuuid
一起使用.我很快就尝试了这个,并没有注意到任何文件描述符泄漏:http://www.ossp.org/pkg/lib/uuid/
If it is libuuid
, the easiest course would be to use the standard library implementation. If speed is a major concern for you, you might look into building a different version of libuuid
to use with python-libuuid
. I tried this one quickly and didn't notice any file descriptors leaking: http://www.ossp.org/pkg/lib/uuid/
我也想知道,用TimeUUID代替timestamp有什么好处?
I also want to know, what is the advantage of using TimeUUID instead of timestamp ?
您将无法更改现有表上列的类型,但可以回答您的问题:TimeUUID 通常用于避免冲突,其中多个事件可以写入相同的时间戳值.
You won't be able to change the type of the column on your existing table, but to answer your question: TimeUUID is usually used to avoid collisions where multiple events could be written in the same timestamp value.
这篇关于默认情况下使用 uuid 时,Cassandra TimeUUID 泛滥文件描述符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!