]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
osd:modify conf, timeout & suicide timeout, of workqueue at runtime to avoid restarti... 31514/head
authorsimon gao <simon29rock@gmail.com>
Mon, 11 Nov 2019 00:16:59 +0000 (19:16 -0500)
committerSimon Gao <simon29rock@gmail.com>
Sun, 22 Nov 2020 00:35:31 +0000 (08:35 +0800)
Signed-off-by: simon gao <simon29rock@gmail.com>
src/common/WorkQueue.h
src/os/filestore/FileStore.cc
src/test/test_workqueue.cc

index 8e9ee405d06454611ad9ce6e7cc1ec6c3324938d..bb9e1b66b633d126d2a27594547ef91fb9a2a562 100644 (file)
@@ -97,6 +97,12 @@ protected:
      * so at most one copy will execute simultaneously for a given thread pool.
      * It can be used for non-thread-safe finalization. */
     virtual void _void_process_finish(void *) = 0;
+    void set_timeout(time_t ti){
+      timeout_interval = ceph::make_timespan(ti);
+    }
+    void set_suicide_timeout(time_t sti){
+      suicide_interval = ceph::make_timespan(sti);
+    }
   };
 
   // track thread pool size changes
index dc304659b1801da526bb3eccc4343397978da6cb..5e9533932ddd9a4239a503ca3adf41f55db025a2 100644 (file)
@@ -6092,6 +6092,8 @@ const char** FileStore::get_tracked_conf_keys() const
     "filestore_sloppy_crc",
     "filestore_sloppy_crc_block_size",
     "filestore_max_alloc_hint_size",
+    "filestore_op_thread_suicide_timeout",
+    "filestore_op_thread_timeout",
     NULL
   };
   return KEYS;
@@ -6160,6 +6162,12 @@ void FileStore::handle_conf_change(const ConfigProxy& conf,
       dump_stop();
     }
   }
+  if (changed.count("filestore_op_thread_timeout")){
+    op_wq.set_timeout(g_conf().get_val<int64_t>("filestore_op_thread_timeout"));
+  }
+  if (changed.count("filestore_op_thread_suicide_timeout")){
+    op_wq.set_suicide_timeout(g_conf().get_val<int64_t>("filestore_op_thread_suicide_timeout"));
+  }
 }
 
 int FileStore::set_throttle_params()
index 0b3daeb05558c356ebd42105c9105877005637d6..5995015addc7bf3507b615b091fa9629715e7ed5 100644 (file)
@@ -53,3 +53,44 @@ TEST(WorkQueue, Resize)
   sleep(1);
   tp.stop();
 }
+
+class twq : public ThreadPool::WorkQueue<int> {
+public:
+    twq(time_t timeout, time_t suicide_timeout, ThreadPool *tp)
+        : ThreadPool::WorkQueue<int>("test_wq", ceph::make_timespan(timeout), ceph::make_timespan(suicide_timeout), tp) {}
+
+    bool _enqueue(int* item) override {
+        return true;
+    }
+    void _dequeue(int* item) override {
+        ceph_abort();
+    }
+    bool _empty() override {
+        return true;
+    }
+    int *_dequeue() override {
+        return nullptr;
+    }
+    void _process(int *osr, ThreadPool::TPHandle &handle) override {
+    }
+    void _process_finish(int *osr) override {
+    }
+    void _clear() override {
+    }
+};
+
+TEST(WorkQueue, change_timeout){
+    ThreadPool tp(g_ceph_context, "bar", "tp_bar", 2, "filestore_op_threads");
+    tp.start();
+    twq wq(2, 20, &tp);
+    // check timeout and suicide
+    ASSERT_EQ(ceph::make_timespan(2), wq.timeout_interval);
+    ASSERT_EQ(ceph::make_timespan(20), wq.suicide_interval);
+
+    // change the timeout and suicide and then check them
+    wq.set_timeout(4);
+    wq.set_suicide_timeout(40);
+    ASSERT_EQ(ceph::make_timespan(4), wq.timeout_interval);
+    ASSERT_EQ(ceph::make_timespan(40), wq.suicide_interval);
+    tp.stop();
+}