Uploaded image for project: 'Couchbase Server'
  1. Couchbase Server
  2. MB-41510

Race in histogram reset and dump

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Major
    • 7.0.0
    • 6.0.0, 6.0.1, 6.0.2, 6.0.3, 6.0.4, 6.0.5, 6.5.1, 6.6.0, 6.5.0
    • couchbase-bucket
    • None
    • Untriaged
    • 1
    • Yes
    • KV Sprint 2020-Oct

    Description

      As part of "stats reset" we call HdrHistogram::reset() which will call

       void HdrHistogram::reset() {
          hdr_reset(histogram.get());
      }
      

      but if someone is currently using the histogram in add_casted_histo_stat they'll end up with an "infinite loop" adding more and more stats:

      template <typename T>
      inline void add_casted_histo_stat(const char* k,
                                        const T& v,
                                        const AddStatFn& add_stat,
                                        const void* cookie) {
          if (v.getValueCount() > 0) {
              std::string meanKey(k);
              meanKey += "_mean";
              add_casted_stat(
                      meanKey.c_str(), std::round(v.getMean()), add_stat, cookie);
       
              HdrHistogram::Iterator iter{v.getHistogramsIterator()};
              while (auto result = v.getNextBucketLowHighAndCount(iter)) {
                  if (std::get<2>(*result) > 0) {
                      std::string newKey(k);
                      newKey += "_" + std::to_string(std::get<0>(*result)) + "," +
                                std::to_string(std::get<1>(*result));
                      add_casted_stat(
                              newKey.c_str(), std::get<2>(*result), add_stat, cookie);
                  }
              }
          }
      }
      

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              richard.demellow Richard deMellow
              trond Trond Norbye
              Votes:
              0 Vote for this issue
              Watchers:
              10 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                PagerDuty