empiredan commented on code in PR #1374:
URL: 
https://github.com/apache/incubator-pegasus/pull/1374#discussion_r1126042317


##########
src/server/pegasus_server_impl.cpp:
##########
@@ -670,41 +673,44 @@ void pegasus_server_impl::on_multi_get(multi_get_rpc rpc)
                                      rpc.remote_address(),
                                      status.ToString());
                 }
-            }
-            // check ttl
-            if (status.ok()) {
-                uint32_t expire_ts = 
pegasus_extract_expire_ts(_pegasus_data_version, value);
-                if (expire_ts > 0 && expire_ts <= epoch_now) {
-                    expire_count++;
-                    if (_verbose_log) {
-                        LOG_ERROR_PREFIX("rocksdb data expired for multi_get 
from {}",
-                                         rpc.remote_address());
-                    }
-                    status = rocksdb::Status::NotFound();
+
+                if (status.IsNotFound()) {
+                    continue;
                 }
+
+                error_occurred = true;
+                final_status = status;
+                break;
             }
-            // extract value
-            if (status.ok()) {
-                // check if exceed limit
-                if (count >= max_kv_count || size >= max_kv_size) {
-                    exceed_limit = true;
-                    break;
-                }
-                ::dsn::apps::key_value kv;
-                kv.key = request.sort_keys[i];
-                if (!request.no_value) {
-                    pegasus_extract_user_data(_pegasus_data_version, 
std::move(value), kv.value);
+
+            // check ttl
+            if (check_if_record_expired(epoch_now, value)) {
+                expire_count++;
+                if (_verbose_log) {
+                    LOG_ERROR_PREFIX(
+                        "rocksdb data expired for multi_get from {}: hash_key 
= \"{}\", "
+                        "sort_key = \"{}\"",
+                        rpc.remote_address(),
+                        ::pegasus::utils::c_escape_string(request.hash_key),
+                        
::pegasus::utils::c_escape_string(request.sort_keys[i]));
                 }
-                count++;
-                size += kv.key.length() + kv.value.length();
-                resp.kvs.emplace_back(std::move(kv));
+                status = rocksdb::Status::NotFound();
+                continue;
             }
-            // if error occurred
-            if (!status.ok() && !status.IsNotFound()) {
-                error_occurred = true;
-                final_status = status;
+
+            // check if exceed limit
+            if (count >= max_kv_count || size >= max_kv_size) {

Review Comment:
   OK, add `dsn_unlikely` here.



##########
src/server/pegasus_server_impl.cpp:
##########
@@ -670,41 +673,44 @@ void pegasus_server_impl::on_multi_get(multi_get_rpc rpc)
                                      rpc.remote_address(),
                                      status.ToString());
                 }
-            }
-            // check ttl
-            if (status.ok()) {
-                uint32_t expire_ts = 
pegasus_extract_expire_ts(_pegasus_data_version, value);
-                if (expire_ts > 0 && expire_ts <= epoch_now) {
-                    expire_count++;
-                    if (_verbose_log) {
-                        LOG_ERROR_PREFIX("rocksdb data expired for multi_get 
from {}",
-                                         rpc.remote_address());
-                    }
-                    status = rocksdb::Status::NotFound();
+
+                if (status.IsNotFound()) {
+                    continue;
                 }
+
+                error_occurred = true;
+                final_status = status;
+                break;
             }
-            // extract value
-            if (status.ok()) {
-                // check if exceed limit
-                if (count >= max_kv_count || size >= max_kv_size) {
-                    exceed_limit = true;
-                    break;
-                }
-                ::dsn::apps::key_value kv;
-                kv.key = request.sort_keys[i];
-                if (!request.no_value) {
-                    pegasus_extract_user_data(_pegasus_data_version, 
std::move(value), kv.value);
+
+            // check ttl
+            if (check_if_record_expired(epoch_now, value)) {
+                expire_count++;
+                if (_verbose_log) {
+                    LOG_ERROR_PREFIX(
+                        "rocksdb data expired for multi_get from {}: hash_key 
= \"{}\", "
+                        "sort_key = \"{}\"",
+                        rpc.remote_address(),
+                        ::pegasus::utils::c_escape_string(request.hash_key),
+                        
::pegasus::utils::c_escape_string(request.sort_keys[i]));
                 }

Review Comment:
   OK, I'll encapsulate this into functions naming `log_expired_data*`.



##########
src/server/pegasus_server_impl.cpp:
##########
@@ -748,25 +754,24 @@ void pegasus_server_impl::on_multi_get(multi_get_rpc rpc)
             expire_count,
             filter_count,
             time_used);
-        _pfc_recent_abnormal_count->increment();
+        METRIC_VAR_INCREMENT(abnormal_read_requests);
     }
 
     if (expire_count > 0) {
-        _pfc_recent_expire_count->add(expire_count);
+        METRIC_VAR_INCREMENT_BY(read_expired_values, expire_count);
     }
     if (filter_count > 0) {
-        _pfc_recent_filter_count->add(filter_count);
+        METRIC_VAR_INCREMENT_BY(read_filtered_values, filter_count);
     }

Review Comment:
   Check if it is zero in `METRIC_VAR_INCREMENT_BY`.



##########
src/server/pegasus_write_service_impl.h:
##########
@@ -689,7 +691,7 @@ class pegasus_write_service::impl : public 
dsn::replication::replica_base
     const std::string _primary_address;
     const uint32_t _pegasus_data_version;
 
-    ::dsn::perf_counter_wrapper &_pfc_recent_expire_count;
+    METRIC_VAR_DECLARE_counter(read_expired_values);

Review Comment:
   This variable can be dropped.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to