Skip to content

mvar clear_stats不是线程安全的 #3069

@lintanghui

Description

@lintanghui

Describe the bug

clear_stats不是线程安全的,在一个线程周周期执行clear_stats用于情况mvar指标,其他线程不停执行get_stats();然后进行赋值会导致coredump
To Reproduce

    bvar::MultiDimension<bvar::LatencyRecorder> mvar("mvar", {"label1", "label2"});
    std::list<std::string> lables = {"v1", "v2"};
    bvar::LatencyRecorder* rec = mvar.get_stats(lables);
// 实际clear_stats是在别的线程执行,处理用于模拟并发操作的情况快速复现
    mvar.clear_stats();
    *rec << 100;

Expected behavior

Versions
OS:
Compiler:
brpc:
protobuf:

Additional context/screenshots

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions