- nebula 版本:3.6.0
- 部署方式: 分布式
- 安装方式: k8s
- 是否上生产环境:N
- 硬件信息
- 磁盘 100g
- CPU、内存信息 4c4g
- 问题的具体描述
- 相关的 meta / storage / graph info 日志信息(尽量使用文本形式方便检索)
下面的计算cache正则存在问题,total_cache=tatal_active_file+total_inactive_file,所以只需要统计total_cache的值就行了,下面这样会导致total_cache多统计了一个total_inactive_file的大小
static const std::regex reTotalCache(R"(^total_(cache|inactive_file)\s+(\d+)$)");
StatusOr<bool> MemoryUtils::hitsHighWatermark() {
......
if (FLAGS_containerized) {
bool cgroupsv2 = FileUtils::exist(FLAGS_cgroup_v2_controllers);
std::string statPath =
cgroupsv2 ? FLAGS_cgroup_v2_memory_stat_path : FLAGS_cgroup_v1_memory_stat_path;
FileUtils::FileLineIterator iter(statPath, &reTotalCache);
uint64_t cacheSize = 0;
for (; iter.valid(); ++iter) {
auto& sm = iter.matched();
cacheSize += std::stoul(sm[2].str(), nullptr);
}
std::string limitPath =
cgroupsv2 ? FLAGS_cgroup_v2_memory_max_path : FLAGS_cgroup_v1_memory_max_path;
auto limitStatus = MemoryUtils::readSysContents(limitPath);
NG_RETURN_IF_ERROR(limitStatus);
uint64_t limitInBytes = std::move(limitStatus).value();
std::string usagePath =
cgroupsv2 ? FLAGS_cgroup_v2_memory_current_path : FLAGS_cgroup_v1_memory_current_path;
auto usageStatus = MemoryUtils::readSysContents(usagePath);
NG_RETURN_IF_ERROR(usageStatus);
uint64_t usageInBytes = std::move(usageStatus).value();
total = static_cast<double>(limitInBytes);
//由于cacheSize的值不正确,导致available的值比实际的偏大,从而导致水位线不准确
available = static_cast<double>(limitInBytes - usageInBytes + cacheSize);
}
......
auto hits = (1 - available / total) > FLAGS_system_memory_high_watermark_ratio;