Skip to content

Commit b60eaa5

Browse files
committed
BugFix: fix the following bugs
- unable to view fiber stack using gdb in python3 - prossible timeout in low qps situation when using connection reuse mode - compatibility with the threadmodel_type field
1 parent 833eac7 commit b60eaa5

File tree

9 files changed

+23
-8
lines changed

9 files changed

+23
-8
lines changed

trpc/client/service_proxy_manager.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ void ServiceProxyManager::SetOptionFromConfig(const ServiceProxyConfig& proxy_co
4141
option->is_reconnection = proxy_conf.is_reconnection;
4242
option->connect_timeout = proxy_conf.connect_timeout;
4343
option->allow_reconnect = proxy_conf.allow_reconnect;
44+
option->threadmodel_type_name = proxy_conf.threadmodel_type;
4445
option->threadmodel_instance_name = proxy_conf.threadmodel_instance_name;
4546
option->service_filters = proxy_conf.service_filters;
4647

trpc/client/service_proxy_option_setter.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ void SetDefaultOption(const std::shared_ptr<ServiceProxyOption>& option) {
9999
option->is_reconnection = kDefaultIsReconnection;
100100
option->connect_timeout = kDefaultConnectTimeout;
101101
option->allow_reconnect = kDefaultAllowReconnect;
102+
option->threadmodel_type_name = kDefaultThreadmodelType;
102103
option->threadmodel_instance_name = "";
103104
option->support_pipeline = kDefaultSupportPipeline;
104105
}
@@ -186,6 +187,9 @@ void SetSpecifiedOption(const ServiceProxyOption* option_ptr, const std::shared_
186187
auto allow_reconnect = GetValidInput<bool>(option_ptr->allow_reconnect, kDefaultAllowReconnect);
187188
SetOutputByValidInput<bool>(allow_reconnect, option->allow_reconnect);
188189

190+
auto threadmodel_type_name = GetValidInput<std::string>(option_ptr->threadmodel_type_name, kDefaultThreadmodelType);
191+
SetOutputByValidInput<std::string>(threadmodel_type_name, option->threadmodel_type_name);
192+
189193
auto threadmodel_instance_name = GetValidInput<std::string>(option_ptr->threadmodel_instance_name, "");
190194
SetOutputByValidInput<std::string>(threadmodel_instance_name, option->threadmodel_instance_name);
191195

trpc/common/config/client_conf_parser.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ struct convert<trpc::ServiceProxyConfig> {
4646
node["recv_buffer_size"] = proxy_config.recv_buffer_size;
4747
node["send_queue_capacity"] = proxy_config.send_queue_capacity;
4848
node["send_queue_timeout"] = proxy_config.send_queue_timeout;
49+
node["threadmodel_type"] = proxy_config.threadmodel_type;
4950
node["threadmodel_instance_name"] = proxy_config.threadmodel_instance_name;
5051
node["selector_name"] = proxy_config.selector_name;
5152
node["namespace"] = proxy_config.namespace_;
@@ -101,6 +102,7 @@ struct convert<trpc::ServiceProxyConfig> {
101102
if (node["recv_buffer_size"]) proxy_config.recv_buffer_size = node["recv_buffer_size"].as<uint32_t>();
102103
if (node["send_queue_capacity"]) proxy_config.send_queue_capacity = node["send_queue_capacity"].as<uint32_t>();
103104
if (node["send_queue_timeout"]) proxy_config.send_queue_timeout = node["send_queue_timeout"].as<uint32_t>();
105+
if (node["threadmodel_type"]) proxy_config.threadmodel_type = node["threadmodel_type"].as<std::string>();
104106
if (node["threadmodel_instance_name"])
105107
proxy_config.threadmodel_instance_name = node["threadmodel_instance_name"].as<std::string>();
106108
if (node["selector_name"]) proxy_config.selector_name = node["selector_name"].as<std::string>();

trpc/common/config/server_conf_parser.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ struct convert<trpc::ServiceConfig> {
4949
node["recv_buffer_size"] = service_config.recv_buffer_size;
5050
node["send_queue_capacity"] = service_config.send_queue_capacity;
5151
node["send_queue_timeout"] = service_config.send_queue_timeout;
52+
node["threadmodel_type"] = service_config.threadmodel_type;
5253
node["threadmodel_instance_name"] = service_config.threadmodel_instance_name;
5354
node["accept_thread_num"] = service_config.accept_thread_num;
5455
node["stream_read_timeout"] = service_config.stream_read_timeout;
@@ -122,6 +123,9 @@ struct convert<trpc::ServiceConfig> {
122123
if (node["send_queue_timeout"]) {
123124
service_config.send_queue_timeout = node["send_queue_timeout"].as<uint32_t>();
124125
}
126+
if (node["threadmodel_type"]) {
127+
service_config.threadmodel_type = node["threadmodel_type"].as<std::string>();
128+
}
125129
if (node["threadmodel_instance_name"]) {
126130
service_config.threadmodel_instance_name = node["threadmodel_instance_name"].as<std::string>();
127131
}

trpc/server/trpc_server.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ void TrpcServer::BuildServiceAdapterOption(const ServiceConfig& config, ServiceA
7171
option.send_queue_capacity = config.send_queue_capacity;
7272
option.send_queue_timeout = config.send_queue_timeout;
7373
option.accept_thread_num = config.accept_thread_num;
74+
option.threadmodel_type = config.threadmodel_type;
7475
option.threadmodel_instance_name = config.threadmodel_instance_name;
7576
option.stream_read_timeout = config.stream_read_timeout;
7677
option.stream_max_window_size = config.stream_max_window_size;

trpc/tools/gdb_plugin/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,4 @@ RIP 0x00000000009249d4 RBP 0x00007f598e5fe8d0 RSP 0x00007f598e5fe880
5656
Found 2 fiber(s) in total.
5757
```
5858
59+
Note: for the production environment, you can use the following command to minimize the impact of debugging on the running service (although this command can still cause a second-level service suspension): `gdb --pid <PID> --eval-command='source gdb_fiber_plugin.py' --eval-command='set pagination off' --eval-command='list-fibers' --batch`.

trpc/tools/gdb_plugin/gdb_fiber_plugin.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ def __init__(self, inferior, fiber_entity_ptr):
136136
saved_state = inferior.read_memory(state_save_area, 0x40)
137137
except GdbMemoryError:
138138
saved_state = '\x00' * 0x40
139+
return None
139140
# @sa: fiber/detail/x86_64/jump_context.S
140141
#
141142
# +---------------------------------------------------------------+
@@ -327,6 +328,8 @@ def try_extract_fiber(inferior, active_frames, offset):
327328
try:
328329
# It's a fiber stack. Otherwise we shouldn't have been called.
329330
fiber = Fiber(inferior, offset - FIBER_STACK_RESERVED_SIZE)
331+
if fiber is None:
332+
return None
330333

331334
if fiber.stack_top == fiber.stack_bottom:
332335
# Master fiber.
@@ -430,6 +433,8 @@ def extract_call_stack(inferior, rip, rbp):
430433
yield rip # Hmmm...
431434
try:
432435
while True:
436+
if rbp == 0:
437+
return
433438
ip = struct.unpack('Q', inferior.read_memory(rbp + 8, 8))[0]
434439
if ip == 0:
435440
return

trpc/transport/client/future/future_tcp_connector_group_manager.cc

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,7 @@
2424
namespace trpc {
2525

2626
FutureTcpConnectorGroupManager::FutureTcpConnectorGroupManager(const Options& options)
27-
: FutureConnectorGroupManager(options) {
28-
if (options_.trans_info->is_complex_conn) {
29-
shared_msg_timeout_handler_ =
30-
std::make_unique<FutureConnComplexMessageTimeoutHandler>(options_.trans_info->rsp_dispatch_function);
31-
TRPC_ASSERT(shared_msg_timeout_handler_ != nullptr);
32-
}
33-
}
27+
: FutureConnectorGroupManager(options) {}
3428

3529
void FutureTcpConnectorGroupManager::Stop() {
3630
if (options_.trans_info->is_complex_conn && timer_id_ != kInvalidTimerId) {
@@ -52,6 +46,9 @@ void FutureTcpConnectorGroupManager::Destroy() {
5246
bool FutureTcpConnectorGroupManager::CreateTimer() {
5347
if (!is_create_timer_) {
5448
if (options_.trans_info->is_complex_conn) {
49+
shared_msg_timeout_handler_ =
50+
std::make_unique<FutureConnComplexMessageTimeoutHandler>(options_.trans_info->rsp_dispatch_function);
51+
TRPC_ASSERT(shared_msg_timeout_handler_ != nullptr);
5552
auto timeout_check_interval = options_.trans_info->request_timeout_check_interval;
5653
timer_id_ = options_.reactor->AddTimerAfter(
5754
0, timeout_check_interval, [this]() { shared_msg_timeout_handler_->DoTimeout(); });

trpc/transport/client/future/future_transport.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ uint16_t FutureTransport::SelectTransportAdapter(CTransportReqMsg* msg, uint16_t
295295
bool FutureTransport::IsSameIOThread(uint16_t index) {
296296
auto* current_thread = WorkerThread::GetCurrentWorkerThread();
297297
if (current_thread && current_thread->Role() != kHandle) {
298-
if (index == GetLogicId(current_thread)) {
298+
if ((index == GetLogicId(current_thread)) && (options_.thread_model->GroupId() == current_thread->GroupId())) {
299299
return true;
300300
}
301301
}

0 commit comments

Comments
 (0)