From 99d9a9da2b86332118fbb60cace4867b03fc027a Mon Sep 17 00:00:00 2001 From: lxfeng1997 <33981743+lxfeng1997@users.noreply.github.com> Date: Mon, 2 Jan 2023 17:57:37 +0800 Subject: [PATCH] bugfix: repair init getty failed (#423) * bugfix: repair init getty failed --- pkg/client/client.go | 15 +++------------ pkg/remoting/getty/listener.go | 7 +++---- 2 files changed, 6 insertions(+), 16 deletions(-) diff --git a/pkg/client/client.go b/pkg/client/client.go index 9508a8ba7..3b1e2433f 100644 --- a/pkg/client/client.go +++ b/pkg/client/client.go @@ -20,13 +20,12 @@ package client import ( "sync" - "github.com/seata/seata-go/pkg/tm" - at "github.com/seata/seata-go/pkg/datasource/sql" "github.com/seata/seata-go/pkg/integration" "github.com/seata/seata-go/pkg/remoting/getty" "github.com/seata/seata-go/pkg/remoting/processor/client" "github.com/seata/seata-go/pkg/rm/tcc" + "github.com/seata/seata-go/pkg/tm" "github.com/seata/seata-go/pkg/util/log" ) @@ -39,7 +38,6 @@ func Init() { func InitPath(configFilePath string) { cfg := LoadPath(configFilePath) - initLog(cfg) initRmClient(cfg) initTmClient(cfg) } @@ -47,13 +45,11 @@ func InitPath(configFilePath string) { var ( onceInitTmClient sync.Once onceInitRmClient sync.Once - onceInitLog sync.Once ) // InitTmClient init client tm client func initTmClient(cfg *Config) { onceInitTmClient.Do(func() { - initRemoting(cfg) tm.InitTm(cfg.ClientConfig.TmConfig) }) } @@ -71,16 +67,11 @@ func initRemoting(cfg *Config) { // InitRmClient init client rm client func initRmClient(cfg *Config) { onceInitRmClient.Do(func() { + log.Init() + initRemoting(cfg) client.RegisterProcessor() integration.Init() tcc.InitTCC() at.InitAT(cfg.ClientConfig.UndoConfig, cfg.AsyncWorkerConfig) }) } - -// initLog init log -func initLog(cfg *Config) { - onceInitLog.Do(func() { - log.Init() - }) -} diff --git a/pkg/remoting/getty/listener.go b/pkg/remoting/getty/listener.go index 4f014245c..4da096b3f 100644 --- a/pkg/remoting/getty/listener.go +++ b/pkg/remoting/getty/listener.go @@ -36,7 +36,6 @@ var ( ) type gettyClientHandler struct { - conf *SeataConfig idGenerator *atomic.Uint32 msgFutures *sync.Map mergeMsgMap *sync.Map @@ -48,7 +47,6 @@ func GetGettyClientHandlerInstance() *gettyClientHandler { if clientHandler == nil { onceClientHandler.Do(func() { clientHandler = &gettyClientHandler{ - conf: getSeataConfig(), idGenerator: &atomic.Uint32{}, msgFutures: &sync.Map{}, mergeMsgMap: &sync.Map{}, @@ -63,11 +61,12 @@ func GetGettyClientHandlerInstance() *gettyClientHandler { func (g *gettyClientHandler) OnOpen(session getty.Session) error { log.Infof("Open new getty session ") g.sessionManager.registerSession(session) + conf := getSeataConfig() go func() { request := message.RegisterTMRequest{AbstractIdentifyRequest: message.AbstractIdentifyRequest{ Version: constant.SeataVersion, - ApplicationId: g.conf.ApplicationID, - TransactionServiceGroup: g.conf.TxServiceGroup, + ApplicationId: conf.ApplicationID, + TransactionServiceGroup: conf.TxServiceGroup, }} err := GetGettyRemotingClient().SendAsyncRequest(request) if err != nil {