You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Cassandra 3.11.7特定分区键查询无结果问题排查求助

问题排查与解决建议

1. 定位主键存储节点并直接查询

执行命令获取目标主键endpoint-i-need对应的存储节点:

nodetool getendpoints m_operational app_settings 'endpoint-i-need'

使用cqlsh分别登录这些节点,直接执行查询语句确认数据是否存在:

select * from m_operational.app_settings where endpoint_id='endpoint-i-need';

若某节点存在数据,说明集群内数据同步异常;若所有节点都无数据,说明插入操作未真正生效。

2. 检查墓碑记录

特定主键无法查询可能源于未清理的墓碑:

  • 查看表的墓碑相关统计:
nodetool tablestats m_operational.app_settings

重点关注Tombstones per slice、Tombstone garbage collection failures等指标。

  • 导出目标节点的sstable文件(路径通常为/var/lib/cassandra/data/m_operational/app_settings-xxxx),用sstable2json解析后搜索目标主键,确认是否存在墓碑标记:
sstable2json /var/lib/cassandra/data/m_operational/app_settings-xxxx/mc-xxx-big-Data.db | grep 'endpoint-i-need'

3. 分析节点日志

查看各节点的system.log(路径通常为/var/log/cassandra/system.log),搜索以下关键词排查异常:

  • endpoint-i-need:定位该主键的读写操作日志
  • repair:检查迁移后repair操作是否报错
  • compaction:确认压缩过程是否存在异常
  • WARN/ERROR:排查数据同步、存储相关的错误信息

4. 验证一致性级别

插入与查询的一致性级别不匹配可能导致数据无法读取:

  • 手动指定一致性级别重新执行插入和查询(注意修正原插入语句的JSON转义错误):
CONSISTENCY QUORUM;
INSERT INTO m_operational.app_settings (endpoint_id, format, settings_json, platform) VALUES( 'endpoint-i-need', 'free', '{"settings": "my-settings"}', 'PC');
CONSISTENCY QUORUM;
select * from m_operational.app_settings where endpoint_id='endpoint-i-need';

5. 修复sstable完整性

在目标主键对应的存储节点上,执行scrub操作修复可能损坏的sstable:

nodetool scrub m_operational app_settings

scrub会验证sstable结构并修复损坏数据,完成后重新查询。

6. 执行全量修复

之前使用-pr参数的peer repair可能未覆盖所有副本,尝试不带该参数的全量修复:

nodetool repair --full m_operational app_settings

注:全量repair会占用较多集群资源,建议在业务低峰期执行。

内容的提问来源于stack exchange,提问作者Nikita Lazarev

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.19 19:37:37