Thanks to visit codestin.com
Credit goes to github.com

Skip to content

consistent_hash_with_group() skips tracing#753

Merged
Barenboim merged 6 commits into
sogou:masterfrom
holmes1412:master
Feb 13, 2022
Merged

consistent_hash_with_group() skips tracing#753
Barenboim merged 6 commits into
sogou:masterfrom
holmes1412:master

Conversation

@holmes1412

Copy link
Copy Markdown
Contributor

No description provided.

@holmes1412 holmes1412 requested a review from wzl12356 February 11, 2022 12:34
return NULL;

return this->check_and_get(addr, false, NULL);
return this->check_and_get(addr, false, tracing);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

这个地方可以传tracing了?那么in_history的判断,好像就可以不用检查tracing==NULL吧?

@holmes1412

Copy link
Copy Markdown
Contributor Author

1. 需求

如果使用ConsistentHash,某台机器重启期间不希望牺牲n=max_failed个请求去把它熔断,而是每个请求可以配retry_max=2,可以保证每个请求第二次重试落到其他备机上。

2. 用法

开发需要为这台机器配上group,server_type = 0,同一个group中为其加入server_type=1的backup。

3. 改动点

当consistent_hash选取到该机器、网络发送失败、进行retry的时候,可以通过tracing避开这台机器。在consistent_hash_with_group()的最后,调用check_and_get(addr, false, tracing)中false表示为弱检查,即万一被选取的addr已达到max_failed:
(1) 没有配group:依然还用这台机器;(与改动前行为相同)
(1) 配了group:通过传入的tracing,在同group的主、备中找到避开tracing且没有熔断的机器;如果还找不到,那就依然返回原机器;

4. 注意

上次的一个改动:d0264e8 添加了一个判断,是在in_select_history()中避免tracing为NULL的情况,说是ConsistentHash的时候会传入NULL。
看了下代码确认,除非当时配了group,否则ConsistentHash中的NULL不调用到in_select_history()。
翻了下没有找到上次说会core的记录,可以后续确认下。

@Barenboim Barenboim merged commit f81b0f4 into sogou:master Feb 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants