Skip to content
This repository has been archived by the owner on Jun 23, 2022. It is now read-only.

meta-server: re-implement returning forward address in configuration_query_b… #217

Merged
merged 1 commit into from
Jan 14, 2019

Conversation

qinzuoyan
Copy link
Member

…y_index_response

we re-implement it in other way to fix compatibility problem of #212

because rpc_address is customized serialized in thrift binary (refer to rpc_address::write), which do not follow the thrift protocal, so the rpc_address cannot be used as extend field.

@qinzuoyan qinzuoyan self-assigned this Jan 13, 2019
@qinzuoyan qinzuoyan added the type/bug-fix This PR fixes a bug. label Jan 13, 2019
@qinzuoyan
Copy link
Member Author

qinzuoyan commented Jan 13, 2019

#212 的实现中,我们企图通过增加扩展字段 forward_address 来返回forward地址。

但是这种方式不可行,因为出现了不兼容问题。由于rpc_address的thrift序列化是自己实现的,但是没有遵从thrift的协议,可能会造成无法反序列化。

所以在这种情况下不兼容:如果server使用新版,返回了扩展的forward address,但是客户端使用旧版,不识别forward_address字段,所以就会试图skip该字段,在skip过程中需要遍历struct结构readStructBegin -> readFieldBegin -> readFieldEnd -> readStructEnd,其中readFieldBegin会读一个字节的field type。但是rdsn中序列化rpc_address时没有写field type。

因此,在thrift_helper.h中自己实现thrift binary seriablization的这些struct都不能作为扩展字段:

  • rpc_address
  • gpid
  • task_code
  • blob
  • error_code

@qinzuoyan
Copy link
Member Author

兼容性测试

Server端版本 Client端版本 Client端配置meta_servers 期望行为 测试结果
新版 新版 包含主MetaServer 正常访问 通过
新版 新版 不包含主MetaServer 正常访问 通过
新版 旧版 包含主MetaServer 正常访问 通过
新版 旧版 不包含主MetaServer 抛出异常 通过
旧版 旧版 包含主MetaServer 正常访问 通过
旧版 旧版 不包含主MetaServer 抛出异常 通过
旧版 新版 包含主MetaServer 正常访问 通过
旧版 新版 不包含主MetaServer 抛出异常 通过

其中:

  • 新版是支持forward address的版本,旧版是指不支持forward address的版本。
  • 可能抛出的异常包括ERR_FORWARD_TO_OTHERS、ERR_SESSEION_RESET、ERR_SERVICE_NOT_ACTIVE、ERR_TIMEOUT等。

@qinzuoyan qinzuoyan changed the title meta: re-implement returning forward address in configuration_query_b… meta-server: re-implement returning forward address in configuration_query_b… Jan 14, 2019

// here we do not use RPC_CHECK_STATUS macro, but specially handle it
// to response forward address.
dinfo("rpc %s called", __FUNCTION__);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

__FUNCTION__ 在这里不是固定的 on_query_configuration_by_index 这个函数吗?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

是的,这里一方面是为了让代码和宏保持一致,一方面如果以后改了函数名,这里也不用改

@qinzuoyan qinzuoyan merged commit 813824f into master Jan 14, 2019
@qinzuoyan qinzuoyan deleted the fix_forward branch January 14, 2019 09:02
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type/bug-fix This PR fixes a bug.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants