Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[ISSUE #11890] Check instance existence before expiring its metadata #11932

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from

Conversation

nkorange
Copy link
Collaborator

@nkorange nkorange commented Apr 8, 2024

Please do not create a Pull Request without creating an issue first.

What is the purpose of the change

Resolve #11890

Brief changelog

Update ExpiredMetadataCleaner to check instance existence before expiring its metadata

Verifying this change

Follow reproducing steps in #11890 to verify.

Checklist

Follow this checklist to help us incorporate your contribution quickly and easily:

  • Make sure there is a Github issue filed for the change (usually before you start working on it). Trivial changes like typos do not require a Github issue. Your pull request should address just this issue, without pulling in other changes - one PR resolves one issue.
  • Format the pull request title like [ISSUE #123] Fix UnknownException when host config not exist. Each commit in the pull request should have a meaningful subject line and body.
  • Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • Write necessary unit-test to verify your logic correction, more mock a little better when cross module dependency exist. If the new feature or significant change is committed, please remember to add integration-test in test module.
  • Run mvn -B clean package apache-rat:check findbugs:findbugs -Dmaven.test.skip=true to make sure basic checks pass. Run mvn clean install -DskipITs to make sure unit-test pass. Run mvn clean test-compile failsafe:integration-test to make sure integration-test pass.

@nkorange nkorange marked this pull request as draft April 8, 2024 07:43
@nkorange nkorange marked this pull request as ready for review April 8, 2024 08:53
@@ -126,4 +127,16 @@ public String toString() {
public static String genMetadataId(String ip, int port, String cluster) {
return ip + InternetAddressUtil.IP_PORT_SPLITER + port + InternetAddressUtil.IP_PORT_SPLITER + cluster;
}

public static String getClusterFromMetadataId(String metadataId) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

这3个方法建议放置到 Cleaner中,作为私有方法

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

这3个方法建议放置到 Cleaner中,作为私有方法

这几个方法只和metadataId的结构有关系,似乎应该放在生成metadataId的地方,并作为公共方法比较好?

Copy link
Collaborator

Choose a reason for hiding this comment

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

但是只有这里有需要使用, 我觉得还是放cleaner里作为私有方法, 如果以后真需要再改。

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

但是只有这里有需要使用, 我觉得还是放cleaner里作为私有方法, 如果以后真需要再改。

问题是如果后面其他地方有需要用,比较难发现某个cleaner已经定义了一个私有方法?

Copy link
Collaborator

Choose a reason for hiding this comment

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

这个问题你放在这里也可能是一样的, 这个必须通过review才可以,如果你一定要单独处理,要不就放到一个工具类里。

我的意见是暂时没有必要, 如果后续有需要,再做抽象即可, 不要为了不存在的需求做所谓的优化。

Copy link
Collaborator Author

@nkorange nkorange Apr 15, 2024

Choose a reason for hiding this comment

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

为啥生成metadataID的方法是在这个类,解析metadataID又要放在别的类呢?这个metadataID本来就算是InstancePublishInfo的一个属性。

当我们有解析metadataID的需求的时候,我觉得很自然会去找到生成metadataID的类去看metadataID的结构,所以这3个方法放在这个类也是很合理的。

Copy link
Collaborator

Choose a reason for hiding this comment

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

因为只有你这个地方要解析, 没有别的地方要解析, 说白了要解析是你这个地方的特殊逻辑,当然要以私有方法方式支持。

Copy link
Collaborator

Choose a reason for hiding this comment

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

要不然你就把所有metadataID的相关操作,都封装到一个工具类里面。

Copy link
Collaborator

Choose a reason for hiding this comment

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

说白了, 现在这个PR只是为了修复这个问题的临时手段, 在临时手段中允许暂时的去解析metadataID,获取对应的数据,先修复问题,不考虑性能和处理手段,长期必须要合理处理这个机制,可能根本就不用去解析metadataId。

所以现在就应该把metadataID的解析工作,收敛到这个特殊的修复逻辑中, 不能发散成为一个通用手段。除非以后确定metadataID需要被拆分解析,如果到了那一步, 我反而倾向吧metadataID变为一个Object,而不是简单的字符串。

Copy link
Collaborator

@KomachiSion KomachiSion left a comment

Choose a reason for hiding this comment

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

3个方法建议放置到 Cleaner中,作为私有方法

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Instance metadata will be lost after Nacos restart
3 participants