-
Notifications
You must be signed in to change notification settings - Fork 59
fix: fix RPC_CHECK_STATUS incorrect usage in meta_service #497
Conversation
} | ||
|
||
template <typename TRpcHolder> | ||
bool meta_service::check_status(TRpcHolder rpc, rpc_address *forward_address) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function name is not self-descriptive enough. Call it try_forward_if_not_leader
I highly recommend you add a unit test here, btw. It seems slightly difficult to mock the case where this meta is not the leader. But since it's necessary, you can add a fail_point to meta_server_failure_detector::get_leader
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think try_forward_if_not_leader
is a good name. Because the main purpose for this function is to do some check work, but not forward
template <typename TRpcHolder> | ||
int check_leader(TRpcHolder rpc, /*out*/ rpc_address *forward_address); | ||
template <typename TRpcHolder> | ||
bool check_status(TRpcHolder rpc, /*out*/ rpc_address *forward_address = nullptr); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I checked all the callers of check_status
. None is using the parameter forward_address
. It's useless I think.
bool check_status(TRpcHolder rpc, /*out*/ rpc_address *forward_address = nullptr); | |
bool check_status(TRpcHolder rpc); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will use it in the later pull request, which needs the forward_address.
In meta_service, there are some rpc interfaces which are using
rpc_holder
. And they useRPC_CHECK_STATUS
to do some check work. But it will cause the response to be sent repeatedly, for example:A response will replied in
RPC_CHECK_STATUS
, and another response will be sent in the dstor of rpc_holder. So one response is sent repeatedly here.If this node is not a master, a forward message will send in this macro, And this situation is same as above.
The implementation of
RPC_CHECK_STATUS
: