默认情况下使用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
- 默认情况下将
uuid1
替换为uuid4
,但是TimeUUID
需要时间部分,只有uuid1
可以提供. - 带有
cassandra.util.uuid_from_time(time.time())
的种族uuid1
,当检查两个uuid1
和
- 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.
最后的选择是将TimeUUID
替换为Timestamp
类型,但是此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
,最简单的方法是使用标准库实现.如果您最关心速度,则可以考虑构建供python-libuuid
使用的其他版本的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代替时间戳有什么好处?
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屋!