简体   繁体   English

Cassandra 服务启动延迟,并在 system.log 文件中读取 SSTables 时出现警告消息“min_index_interval of 128 is too low”

[英]Cassandra service startup delays with WARN message "min_index_interval of 128 is too low" while reading SSTables in system.log file

We found a delay of 2 hrs in starting the Cassandra service with WARN in the system.log file for one table.我们发现在一个表的 system.log 文件中使用 WARN 启动 Cassandra 服务有 2 小时的延迟。 Please find the warnings in a few of the below servers: WARN [SSTableBatchOpen:5] 2022-08-29 10:01:13,732 IndexSummaryBuilder.java:115 - min_index_interval of 128 is too low for 5511836446 expected keys of avg size 64;请在以下几个服务器中找到警告:WARN [SSTableBatchOpen:5] 2022-08-29 10:01:13,732 IndexSummaryBuilder.java:115 - min_index_interval 的 128 对于 5511836446 个预期的 avg 大小的键来说太低了; using interval of 185 instead改为使用 185 的间隔

Aaron's answer pointed to the right code: Since you have a LOT of keys in a single SSTable, the default min_index_interval is not efficient anymore and Cassandra recomputes it. Aaron 的回答指出了正确的代码:由于您在单个 SSTable 中有很多键,因此默认的min_index_interval不再有效,Cassandra 会重新计算它。 This then triggers a rewrite of the index summary during startup, and in this very case it's taking a very long time.然后这会在启动期间触发索引摘要的重写,在这种情况下,它需要很长时间。 Aaron's suggestion of using sstablesplit would be a temporary fix as eventually they'll get compacted again and you'll be back to the same situation. Aaron 建议使用sstablesplit将是一个临时修复,因为最终它们会再次被压缩,你会回到同样的情况。

Changes will have to be made in production to remediate anyway, and changing the min_index_interval seems easy enough as a fix, while really being the only thing to do that won't require deep schema changes to reduce the number of partitions per sstable (or compaction strategy changes which could have hard to predict performance impacts).无论如何都必须在生产中进行更改以进行修复,并且更改min_index_interval作为修复似乎很容易,而实际上是唯一不需要深度模式更改以减少每个 sstable 的分区数量(或压缩可能难以预测性能影响的战略变化)。

Note that changing the min_index_interval will not trigger the rewrite of the sstables straight away.请注意,更改min_index_interval不会立即触发 sstable 的重写。 Only newly written sstables will get the new setting, which can be (and should be) forced onto all the sstables using nodetool upgradesstables -a .只有新编写的 sstables 才会获得新设置,可以(并且应该)使用nodetool upgradesstables -a将其强制到所有 sstables 上。

On a side note, there seem to be a confusion in the comments between the partition index and secondary indexes (indices?).附带说明一下,分区索引和二级索引(索引?)之间的注释似乎存在混淆。 They are two distinct things and the reported warning message is referring to the partition index summary, not secondary indexes.它们是两个不同的东西,报告的警告消息是指分区索引摘要,而不是二级索引。

It's difficult to discern a question from the above, so I'll assume you're wondering why Cassandra is taking 2 hours to start up.从上面很难辨别出一个问题,所以我假设您想知道为什么 Cassandra 需要 2 小时才能启动。

If you look in the source of Cassandra 3.0, there are some clues given in the IndexSummaryBuilder class.如果您查看 Cassandra 3.0 的源代码, IndexSummaryBuilder class 中给出了一些线索。 Specifically, the calculations just prior to the warning:具体来说,就在警告之前的计算:

if (maxExpectedEntriesSize > Integer.MAX_VALUE)
{
    // that's a _lot_ of keys, and a very low min index interval
    int effectiveMinInterval = (int) Math.ceil((double)(expectedKeys * expectedEntrySize) / Integer.MAX_VALUE);
    maxExpectedEntries = expectedKeys / effectiveMinInterval;
    maxExpectedEntriesSize = maxExpectedEntries * expectedEntrySize;
    assert maxExpectedEntriesSize <= Integer.MAX_VALUE : maxExpectedEntriesSize;
    logger.warn("min_index_interval of {} is too low for {} expected keys of avg size {}; using interval of {} instead",
                minIndexInterval, expectedKeys, defaultExpectedKeySize, effectiveMinInterval);

The comment about " that's a _lot_ of keys " is a big one, and 5,511,836,446 keys is certainly a lot.关于“ that's a _lot_ of keys ”的评论很大, 5,511,836,446键肯定很多。

The calculations shown in the method above are driven by the number of keys and sampling intervals for a particular SSTable, to build the Partition Summary into RAM.上述方法中显示的计算由特定 SSTable 的键数和采样间隔驱动,以将 Partition Summary 构建到 RAM 中。 You can see the Partition Summary on the right side of the diagram showing Cassandra's read path below:您可以在图表右侧看到显示 Cassandra 读取路径的 Partition Summary:

在此处输入图像描述

Based on this, I would hypothesize that one particular table's SSTable file(s) is getting too big to handle efficiently.基于此,我假设一个特定表的 SSTable 文件变得太大而无法有效处理。 Have a look at the underlying data directory for that table.查看该表的基础数据目录。 You may have to split some of those files with tools/bin/sstablesplit to make them more manageable.您可能必须使用tools/bin/sstablesplit 拆分其中一些文件,以使它们更易于管理。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM