You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pegasus.apache.org by GitBox <gi...@apache.org> on 2020/10/20 08:20:58 UTC

[GitHub] [incubator-pegasus] neverchanje commented on a change in pull request #625: feat(hotkey): collector can be terminated by timeout

neverchanje commented on a change in pull request #625:
URL: https://github.com/apache/incubator-pegasus/pull/625#discussion_r508302601



##########
File path: src/server/hotkey_collector.cpp
##########
@@ -21,16 +21,23 @@
 #include <dsn/utility/smart_pointers.h>
 #include "base/pegasus_key_schema.h"
 #include <dsn/dist/fmt_logging.h>
+#include <dsn/utility/flags.h>
 
 namespace pegasus {
 namespace server {
 
+DSN_DEFINE_int32("pegasus.server",
+                 hotkey_collector_max_work_time,
+                 150,
+                 "the max time allowed to capture hotkey, will stop if hotkey's not found");

Review comment:
       ```suggestion
                    "the max time (in seconds) allowed to capture hotkey, will stop if hotkey's not found");
   ```

##########
File path: src/server/hotkey_collector.cpp
##########
@@ -105,13 +117,30 @@ void hotkey_collector::on_start_detect(dsn::replication::detect_hotkey_response
 
 void hotkey_collector::on_stop_detect(dsn::replication::detect_hotkey_response &resp)
 {
-    _state.store(hotkey_collector_state::STOPPED);
-    _internal_collector.reset();
+    terminate_colletor();
     resp.err = dsn::ERR_OK;
     std::string hint =
         fmt::format("{} hotkey stopped, cache cleared", dsn::enum_to_string(_hotkey_type));
     ddebug_replica(hint);
 }
 
+void hotkey_collector::terminate_colletor()
+{
+    _state.store(hotkey_collector_state::STOPPED);
+    _internal_collector.reset();
+    _collector_start_time = 0;
+}
+
+void hotkey_collector::terminate_by_timeout()
+{
+    if (dsn_now_s() == 0)
+        return;

Review comment:
       ```suggestion
       if (dsn_now_s() == 0)
           return;
   ```
   
   No such thing that now_s returns 0. What does this supposed to mean?




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@pegasus.apache.org
For additional commands, e-mail: dev-help@pegasus.apache.org