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

fix: The metadata invoker is destroyed too early #2322

Merged
merged 1 commit into from
May 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
15 changes: 6 additions & 9 deletions config/provider_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,19 +164,16 @@ func (c *ProviderConfig) Load() {
continue
}
// service doesn't config in config file, create one with default
logger.Warnf("Dubbogo can not find service with registeredTypeName %s in configuration. Use the default configuration instead.", registeredTypeName)
supportPBPackagerNameSerivce, ok := service.(common.TriplePBService)
serviceConfig = NewServiceConfigBuilder().Build()
if !ok {
logger.Errorf("Dubbogo do not read service interface name with registeredTypeName = %s."+
"Please run go install github.com/dubbogo/dubbogo-cli/cmd/protoc-gen-go-triple@latest to update your "+
"protoc-gen-go-triple and re-generate your pb file again."+
"If you are not using pb serialization, please set 'interface' field in service config.", registeredTypeName)
logger.Warnf(
"The provider service %s is ignored: neither the config is found, nor it is a valid Triple service.",
registeredTypeName)
continue
} else {
// use interface name defined by pb
serviceConfig.Interface = supportPBPackagerNameSerivce.XXX_InterfaceName()
}
serviceConfig = NewServiceConfigBuilder().Build()
// use interface name defined by pb
serviceConfig.Interface = supportPBPackagerNameSerivce.XXX_InterfaceName()
if err := serviceConfig.Init(rootConfig); err != nil {
logger.Errorf("Service with refKey = %s init failed with error = %s")
}
Expand Down
13 changes: 9 additions & 4 deletions config/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,9 @@ package config

import (
"sync"
)

import (
"dubbo.apache.org/dubbo-go/v3/common"
"github.com/dubbogo/gost/log/logger"
)

var (
Expand All @@ -38,15 +37,21 @@ var (
func SetConsumerService(service common.RPCService) {
ref := common.GetReference(service)
conServicesLock.Lock()
defer conServicesLock.Unlock()
defer func() {
conServicesLock.Unlock()
logger.Debugf("A consumer service %s was registered successfully.", ref)
}()
conServices[ref] = service
}

// SetProviderService is called by init() of implement of RPCService
func SetProviderService(service common.RPCService) {
ref := common.GetReference(service)
proServicesLock.Lock()
defer proServicesLock.Unlock()
defer func() {
proServicesLock.Unlock()
logger.Debugf("A provider service %s was registered successfully.", ref)
}()
proServices[ref] = service
}

Expand Down
2 changes: 0 additions & 2 deletions metadata/service/local/service_proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,6 @@ func (m *MetadataServiceProxy) GetMetadataInfo(revision string) (*common.Metadat
invocation.WithAttachments(map[string]interface{}{constant.AsyncKey: "false"}),
invocation.WithParameterValues([]reflect.Value{rV}))
res := m.invkr.Invoke(context.Background(), inv)
// when request finished, invoker will colse
defer m.invkr.Destroy()
if res.Error() != nil {
logger.Errorf("could not get the metadata info from remote provider: %v", res.Error())
return nil, res.Error()
Expand Down