为 Cassandra DDL 设置一致性级别 [英] SET consistency level for Cassandra DDL

查看:31
本文介绍了为 Cassandra DDL 设置一致性级别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用程序日志中,我看到,默认情况下,在运行 create/alter table 语句后,cassandra 驱动程序似乎会进行处理以使模式达成一致长达 10 秒.

In my application logs I've seen that, by default, after running create/alter table statements, cassandra driver seems to do processing to bring schema into agreement for up to 10 seconds.

在执行诸如创建表..如果不存在"之类的 DDL 语句时,我是否可以(并且应该)设置一致性级别,例如仲裁",以确保我的表被创建并传播到所有节点?

Can I (and should I) set a consistency level for example 'quorum' while executing DDL statements like 'Create Table .. IF NOT EXISTS' to make sure my table gets created and propagated to all nodes?

推荐答案

Cassandra 中的架构更改(数据定义)自 1.1+ 开始通过 八卦.由于它使用 Gossip,它是一个与典型数据操作请求(SELECT、DELETE、INSERT 等)不同的读/写路径,因此对于此类操作没有可调一致性,因为 gossip 不以可调一致性运行.从我链接的文章中,您可以看到架构更改在集群中被动宣布,此外,如果在进行架构更改时无法访问节点,您可以获得架构不一致/解决方案.

Schema changes (data definition) in Cassandra since 1.1+ are done via gossip. Since it uses Gossip, it is a separate read/write path than your typical data manipulation requests (SELECT, DELETE, INSERT, etc), and hence has no tunable consistency for such operations, since gossip doesn't operate with tunable consistency. From the article I linked, you can see that schema changes are passively announced in the cluster, and furthermore you can get schema disagreement/resolution when you have nodes that were unreachable when the schema change was made.

您多久修改一次架构?如您所见,架构更改虽然比以前有了很大改进,但仍然是一项非常昂贵的操作,因为每个节点都必须保持一致.出于这个原因,应该避免在 Cassandra 中频繁更改架构(也称为动态列).我很想知道架构更改的频率和原因,也许您可​​以重构以避免动态列/表,以避免在 Cassandra 中进行昂贵的架构更改.

How often are you modifying your schema? As you can see schema changes, while vastly improved from what it used to be, is still a very expensive operation as every node has to become consistent. Frequent schema changes in Cassandra should be avoided (aka dynamic columns) for this reason. I would be curious to hear how often and why the schema is being change, perhaps you could remodel to avoid dynamic columns/tables to avoid expensive schema changes in Cassandra.

这篇关于为 Cassandra DDL 设置一致性级别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆