diff --git a/src/observer/mysql/ob_query_response_time.cpp b/src/observer/mysql/ob_query_response_time.cpp index de2f8484b3575d87a84d4fe4f40660fc7c7ed90c..e0f89439585ef8406426060321b7e3c697ea7816 100644 --- a/src/observer/mysql/ob_query_response_time.cpp +++ b/src/observer/mysql/ob_query_response_time.cpp @@ -71,7 +71,7 @@ int ObRSTUtility::setup(uint base) return 0; } -ObRSTTimeCollector::ObRSTTimeCollector():mutex_() +ObRSTTimeCollector::ObRSTTimeCollector() { flush(); } @@ -81,8 +81,8 @@ ObRSTTimeCollector::~ObRSTTimeCollector() int ObRSTTimeCollector::flush() { for(int i = 0; i < OB_QRT_OVERALL_COUNT + 1; i++) { - count_[i] = 0; - total_[i] = 0; + ATOMIC_SET(&count_[i], 0); + ATOMIC_SET(&total_[i], 0); } return 0; } @@ -92,8 +92,8 @@ int ObRSTTimeCollector::collect(uint64_t time) int i = 0; for(int count = utility_.bound_count(); count > i; ++i) { if(utility_.bound(i) > time) { - count_[i]++; - total_[i] += time; + ATOMIC_INC(&count_[i]); + ATOMIC_FAA(&total_[i],time); break; } } @@ -140,7 +140,6 @@ int ObRSTCollector::collect_query_response_time(uint64_t tenant_id, uint64_t tim if (OB_FAIL(ret = collector_map_.get_refactored(tenant_id, time_collector))){ SERVER_LOG(WARN, "time collector of the tenant does not exist", K(tenant_id), K(time), K(ret)); } else { - lib::ObMutexGuard guard(time_collector->mutex_); if(OB_FAIL(ret = time_collector->collect(time))){ SERVER_LOG(WARN, "time collector of the tenant collect time failed", K(tenant_id), K(time), K(ret)); } @@ -163,7 +162,6 @@ int ObRSTCollector::flush_query_response_time(uint64_t tenant_id,const ObString& if (OB_FAIL(ret = collector_map_.get_refactored(tenant_id, time_collector))){ SERVER_LOG(WARN, "time collector of the tenant does not exist", K(ret), K(tenant_id)); } else { - lib::ObMutexGuard guard(time_collector->mutex_); if (OB_FAIL(ret = time_collector->setup(tenant_config->query_response_time_range_base))){ SERVER_LOG(WARN, "time collector of the tenant set range base failed", K(ret), K(tenant_id)); } else if (OB_FAIL(ret = time_collector->flush())){ diff --git a/src/observer/mysql/ob_query_response_time.h b/src/observer/mysql/ob_query_response_time.h index 5d23cc9cfc419a3010d7e146813af8a97e90f8d5..32173ed473d6e7b156d03011a4cc739022e2a92e 100644 --- a/src/observer/mysql/ob_query_response_time.h +++ b/src/observer/mysql/ob_query_response_time.h @@ -69,7 +69,6 @@ class ObRSTTimeCollector { public: ObRSTUtility utility_; - lib::ObMutex mutex_; uint32_t count_[OB_QRT_OVERALL_COUNT]; uint64_t total_[OB_QRT_OVERALL_COUNT];