This is an automated email from the ASF dual-hosted git repository.
flypiggy pushed a commit to branch feature/support-raft
in repository https://gitbox.apache.org/repos/asf/incubator-seata-go.git
The following commit(s) were added to refs/heads/feature/support-raft by this
push:
new c16914c9 Update raft.go
c16914c9 is described below
commit c16914c971c36d3848a91f1b30210ca9d7612d5d
Author: 福來|Fulai <[email protected]>
AuthorDate: Thu Mar 5 04:18:36 2026 +0800
Update raft.go
---
pkg/discovery/raft.go | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/pkg/discovery/raft.go b/pkg/discovery/raft.go
index 33455d69..72e2df7f 100644
--- a/pkg/discovery/raft.go
+++ b/pkg/discovery/raft.go
@@ -87,8 +87,10 @@ func (r *RaftRegistryService) Lookup(key string)
([]*ServiceInstance, error) {
if clusterName == "" {
return nil, fmt.Errorf("cluster doesnt exist")
}
+ r.mu.Lock()
r.currentTransactionServiceGroup = key
r.currentTransactionClusterName = clusterName
+ r.mu.Unlock()
if !r.metadata.ContainsGroup(clusterName) {
if _, ok := r.loadInitAddresses(clusterName); !ok &&
r.cfg.ServerAddr != "" {
@@ -239,7 +241,9 @@ func (r *RaftRegistryService) startQueryMetadata() {
}
if shouldFetch {
+ r.mu.RLock()
clusterName :=
r.currentTransactionClusterName
+ r.mu.RUnlock()
groups :=
r.metadata.Groups(clusterName)
if len(groups) == 0 {
groups =
append(groups, "")
@@ -436,7 +440,9 @@ func (r *RaftRegistryService) queryHttpAddress(clusterName,
group string) (strin
}
if len(nodes) > 0 {
+ r.mu.RLock()
currentServiceGroup := r.currentTransactionServiceGroup
+ r.mu.RUnlock()
if aliveAny, ok := r.aliveNodes.Load(currentServiceGroup); ok {
aliveNodes, ok := aliveAny.([]*ServiceInstance)
if !ok {
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]