Repository: JDRaftKeeper/RaftKeeper (language: cpp)

Issue:
Add name to NIO threads
### Description
<!-- Describe the enhancement you want, including the motivation. -->
It is usefull to debug.

### Are you willing to submit PR?



Discussion / hints:

Fix patch:
diff --git a/programs/server/Server.cpp b/programs/server/Server.cpp
index 2016480349..85df6584e7 100644
--- a/programs/server/Server.cpp
+++ b/programs/server/Server.cpp
@@ -168,11 +168,12 @@ int Server::main(const std::vector<std::string> & /*args*/)
             socket.setBlocking(false);
 
             Poco::Timespan timeout(operation_timeout_ms * 1000);
-            server = std::make_shared<SvsSocketReactor<SocketReactor>>(timeout, "IO-SrvAcceptor");
+            server = std::make_shared<SvsSocketReactor<SocketReactor>>(timeout, "IO-Acptr");
 
             /// TODO add io thread count to config
+            static UInt64 handler_thread_id = 0;
             conn_acceptor = std::make_shared<SvsSocketAcceptor<ConnectionHandler, SocketReactor>>(
-                "IO-SrvHandler", global_context, socket, *server, timeout, cpu_core_size);
+                "IO-Hdlr-" + std::to_string(handler_thread_id++), global_context, socket, *server, timeout, cpu_core_size);
             LOG_INFO(log, "Listening for user connections on {}", socket.address().toString());
         });
 
@@ -191,11 +192,12 @@ int Server::main(const std::vector<std::string> & /*args*/)
             socket.setBlocking(false);
 
             Poco::Timespan timeout(operation_timeout_ms * 1000);
-            forwarding_server = std::make_shared<SvsSocketReactor<SocketReactor>>(timeout, "IO-FwdAcceptor");
+            forwarding_server = std::make_shared<SvsSocketReactor<SocketReactor>>(timeout, "IO-FwdAcptr");
 
             /// TODO add io thread count to config
+            static UInt64 handler_thread_id = 0;
             forwarding_conn_acceptor = std::make_shared<SvsSocketAcceptor<ForwardingConnectionHandler, SocketReactor>>(
-                "IO-FwdHandler", global_context, socket, *forwarding_server, timeout, cpu_core_size);
+                "IO-FwdHdlr-" + std::to_string(handler_thread_id++), global_context, socket, *forwarding_server, timeout, cpu_core_size);
             LOG_INFO(log, "Listening for forwarding connections on {}", socket.address().toString());
         });
 
diff --git a/src/Common/NIO/SvsSocketReactor.h b/src/Common/NIO/SvsSocketReactor.h
index 50b8a89dee..47f33fba5b 100644
--- a/src/Common/NIO/SvsSocketReactor.h
+++ b/src/Common/NIO/SvsSocketReactor.h
@@ -23,7 +23,10 @@ class SvsSocketReactor : public SR
     {
         _thread.start(*this);
         if (!name.empty())
+        {
             _thread.setName(name);
+            setThreadName(name.c_str());
+        }
     }
 
     SvsSocketReactor(const Poco::Timespan& timeout, const std::string& name = ""):
@@ -31,7 +34,10 @@ class SvsSocketReactor : public SR
     {
         _thread.start(*this);
         if (!name.empty())
+        {
             _thread.setName(name);
+            setThreadName(name.c_str());
+        }
     }
 
     ~SvsSocketReactor() override


Test patch: