Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

bugfix: change group and node offline status are not pushed in real time #6812

Merged
merged 26 commits into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
50c77dc
add signature
ggbocoder Jan 2, 2024
b36f5b2
Merge remote-tracking branch 'upstream/2.x' into 2.x
ggbocoder Jan 20, 2024
e15537d
Merge remote-tracking branch 'upstream/2.x' into 2.x
ggbocoder Jan 25, 2024
85398ec
Merge remote-tracking branch 'upstream/2.x' into 2.x
ggbocoder Jan 31, 2024
e049125
Merge remote-tracking branch 'upstream/2.x' into 2.x
ggbocoder Mar 7, 2024
2939f59
Merge remote-tracking branch 'upstream/2.x' into 2.x
ggbocoder May 12, 2024
ebeda3a
Merge remote-tracking branch 'upstream/2.x' into 2.x
ggbocoder Jul 5, 2024
f2f9509
Merge branch '2.x' of https://github.com/seata/seata into 2.x
ggbocoder Jul 7, 2024
eed8785
Merge branch '2.x' of https://github.com/seata/seata into 2.x
ggbocoder Jul 15, 2024
5147f84
Merge branch '2.x' of https://github.com/seata/seata into 2.x
ggbocoder Jul 28, 2024
f6f4293
Merge branch '2.x' of https://github.com/seata/seata into 2.x
ggbocoder Aug 3, 2024
858aabd
Merge branch '2.x' of https://github.com/seata/seata into 2.x
ggbocoder Aug 14, 2024
f90f421
Merge branch '2.x' of https://github.com/seata/seata into 2.x
ggbocoder Aug 17, 2024
64a1040
Merge branch '2.x' of https://github.com/seata/seata into 2.x
ggbocoder Aug 19, 2024
892d030
Merge remote-tracking branch 'upstream/2.x' into 2.x
ggbocoder Aug 23, 2024
9422ddd
Merge branch '2.x' of https://github.com/seata/seata into 2.x
ggbocoder Aug 24, 2024
aa805d3
Merge branch '2.x' of https://github.com/seata/seata into 2.x
ggbocoder Aug 28, 2024
95591cc
Merge remote-tracking branch 'upstream/2.x' into 2.x
ggbocoder Aug 31, 2024
6876f1c
Merge remote-tracking branch 'upstream/2.x' into 2.x
ggbocoder Sep 3, 2024
d14deb1
Merge remote-tracking branch 'upstream/2.x' into 2.x
ggbocoder Sep 4, 2024
5519fbd
fix
ggbocoder Sep 4, 2024
abb4489
fix
ggbocoder Sep 4, 2024
c4e55f5
Update namingserver/src/main/java/org/apache/seata/namingserver/manag…
ggbocoder Sep 4, 2024
46472e3
Update namingserver/src/main/java/org/apache/seata/namingserver/manag…
ggbocoder Sep 4, 2024
74555a8
fix
ggbocoder Sep 4, 2024
c826e55
fix
ggbocoder Sep 4, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changes/en-us/2.x.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ Add changes here for all PR submitted to the 2.x branch.
- [[#6797](https://github.com/apache/incubator-seata/pull/6797)] fall back to any of available cluster address when query cluster address is empty
- [[#6800](https://github.com/apache/incubator-seata/pull/6800)] make exception message generic for all database drivers
- [[#6759](https://github.com/apache/incubator-seata/pull/6759)] fix the error of active refresh failure of cross-database table metadata
- [[#6812](https://github.com/apache/incubator-seata/pull/6812)] bugfix: change group and node offline status are not pushed in real time


### optimize:
Expand Down
1 change: 1 addition & 0 deletions changes/zh-cn/2.x.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
- [[#6781](https://github.com/apache/incubator-seata/pull/6781)] 修复tc下线时,由于定时任务没有先关闭,导致下线后还会被注册上,需要靠namingserver的健康检查来下线的bug
- [[#6797](https://github.com/apache/incubator-seata/pull/6797)] 当查询的集群地址为空时,获取可用的任意集群地址
- [[#6800](https://github.com/apache/incubator-seata/pull/6800)] 使异常消息对所有数据库驱动程序通用
- - [[#6812](https://github.com/apache/incubator-seata/pull/6812)] 修复切换事务分组和节点下线时namingserver没有实时感知和推送的bug

- [[#6759](https://github.com/apache/incubator-seata/pull/6759)] 修复跨库表主动刷新`tableMeta`的异常问题

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,6 @@ public List<InetSocketAddress> refreshGroup(String vGroup) throws IOException {
throw new NamingRegistryException("cannot lookup server list in vgroup: " + vGroup);
}
String jsonResponse = EntityUtils.toString(response.getEntity(), "UTF-8");
response.close();
// jsonResponse -> MetaResponse
MetaResponse metaResponse = OBJECT_MAPPER.readValue(jsonResponse, new TypeReference<MetaResponse>() {
});
Expand All @@ -375,6 +374,7 @@ public List<InetSocketAddress> refreshGroup(String vGroup) throws IOException {
term = metaResponse.getTerm();
}
VGROUP_ADDRESS_MAP.put(vGroup, newAddressList);
removeOfflineAddressesIfNecessary(vGroup,vGroup,newAddressList);
} catch (IOException e) {
LOGGER.error(e.getMessage());
throw new RemoteException();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,9 +224,9 @@ public void notifyClusterChange(String vGroup, String namespace, String clusterN

Optional.ofNullable(vGroupMap.asMap().get(vGroup)).flatMap(map -> Optional.ofNullable(map.get(namespace)).flatMap(namespaceBO -> Optional.ofNullable(namespaceBO.getCluster(clusterName)))).ifPresent(clusterBO -> {
Set<String> units = clusterBO.getUnitNames();
ggbocoder marked this conversation as resolved.
Show resolved Hide resolved
if (StringUtils.isBlank(unitName) || units.contains(unitName)) {
applicationContext.publishEvent(new ClusterChangeEvent(this, vGroup, term));
}
// if (!CollectionUtils.isEmpty(units)) {
applicationContext.publishEvent(new ClusterChangeEvent(this, vGroup, term));
// }
});
}

Expand Down Expand Up @@ -276,7 +276,7 @@ public boolean unregisterInstance(String namespace, String clusterName, String u
if (vgroupMap instanceof Map) {
((Map<String, Object>) vgroupMap).forEach((group, realUnitName) -> {
vGroupMap.get(group, k -> new ConcurrentHashMap<>())
.get(namespace).getCluster(clusterName).remove(realUnitName == null ? unitName : (String) realUnitName);
.get(namespace).getCluster(clusterName).remove(realUnitName == null ? unitName : (String) realUnitName);
notifyClusterChange(group, namespace, clusterName, unitName, node.getTerm());
});
}
Expand Down Expand Up @@ -367,17 +367,23 @@ public Result<String> changeGroup(String namespace, String vGroup, String cluste
namespaceClusters.put(currentNamespace,
new HashSet<>(namespaceMap.get(currentNamespace).getClusterMap().keySet()));
}
createGroup(namespace, vGroup, clusterName, unitName);
Result<String> res = createGroup(namespace, vGroup, clusterName, unitName);
if (!res.isSuccess()) {
LOGGER.error("add vgroup failed!" + res.getMessage());
return res;
}
AtomicReference<Result<String>> result = new AtomicReference<>();
namespaceClusters.forEach((oldNamespace, clusters) -> {
for (String cluster : clusters) {
Optional.ofNullable(namespaceClusterDataMap.get(oldNamespace))
.flatMap(map -> Optional.ofNullable(map.get(cluster))).ifPresent(clusterData -> {
if (!CollectionUtils.isEmpty(clusterData.getUnitData())) {
clusterData.getUnitData().forEach((unit, unitData) -> result
.set(removeGroup(unitData, vGroup, cluster, oldNamespace, unitName)));
}
});
if (!CollectionUtils.isEmpty(clusterData.getUnitData())) {
clusterData.getUnitData().forEach((unit, unitData) -> {
result.set(removeGroup(unitData, vGroup, cluster, oldNamespace, unitName));
notifyClusterChange(vGroup, namespace, cluster, unit, -1);
ggbocoder marked this conversation as resolved.
Show resolved Hide resolved
});
}
});
}
});
return Optional.ofNullable(result.get()).orElseGet(() -> new Result<>("200", "change vGroup successfully!"));
Expand Down
Loading