默认情况下使用 uuid 时的 Cassandra TimeUUID 泛洪文件描述符

Cassandra TimeUUID flood file descriptor when use uuid in default

我有 Cassandra 模型

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 creation doesn't close files - hits file descriptor limit。我试图找到解决方案,但似乎我认为哪些选项可能行不通

最后一个选项是将 TimeUUID 替换为 Timestamp 类型,但是此 created_at 列是 primary_keyclustering_order,所以不知道我能做什么不管是不是。

我的专栏家族已经有1,000,000+条数据了,我舍不得扔掉。

我也想知道,用TimeUUID代替timestamp有什么好处?

您确定您遇到了您链接的 libuuid 问题吗?您的代码片段显示了标准库 uuid,它可能没有这个问题。您的程序中是否可能存在不同的文件描述符泄漏?

如果是libuuid,最简单的方法就是使用标准库实现。如果速度是您的主要关注点,您可能会考虑构建一个不同版本的 libuuid 以与 python-libuuid 一起使用。我很快尝试了这个,没有注意到任何文件描述符泄漏:http://www.ossp.org/pkg/lib/uuid/

I also want to know, what is the advantage of using TimeUUID instead of timestamp ?

您将无法更改现有 table 上的列类型,但可以回答您的问题:TimeUUID 通常用于避免可能在同一时间戳中写入多个事件的冲突值。