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: save plugin db is locked #2080

Merged
merged 1 commit into from
Nov 27, 2024
Merged
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
8 changes: 4 additions & 4 deletions api/handler/service_plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ func (s *ServiceAction) SetTenantServicePluginRelation(tenantID, serviceID strin
p.ListenPort = pluginPort
}
}
if err := s.SavePluginConfig(serviceID, plugin.PluginID, pss.Body.ConfigEnvs.ComplexEnvs); err != nil {
if err := s.SavePluginConfig(serviceID, plugin.PluginID, pss.Body.ConfigEnvs.ComplexEnvs, tx); err != nil {
tx.Rollback()
return nil, util.CreateAPIHandleError(500, fmt.Errorf("set complex error, %v", err))
}
Expand Down Expand Up @@ -261,7 +261,7 @@ func (s *ServiceAction) UpdateVersionEnv(uve *apimodel.SetVersionEnv) *util.APIH
p.ListenPort = pluginPort
}
}
if err := s.SavePluginConfig(uve.Body.ServiceID, uve.PluginID, uve.Body.ConfigEnvs.ComplexEnvs); err != nil {
if err := s.SavePluginConfig(uve.Body.ServiceID, uve.PluginID, uve.Body.ConfigEnvs.ComplexEnvs, tx); err != nil {
tx.Rollback()
return util.CreateAPIHandleError(500, fmt.Errorf("update complex error, %v", err))
}
Expand Down Expand Up @@ -291,7 +291,7 @@ func (s *ServiceAction) upNormalEnvs(tx *gorm.DB, uve *apimodel.SetVersionEnv) *
}

// SavePluginConfig save plugin dynamic discovery config
func (s *ServiceAction) SavePluginConfig(serviceID, pluginID string, config *apimodel.ResourceSpec) *util.APIHandleError {
func (s *ServiceAction) SavePluginConfig(serviceID, pluginID string, config *apimodel.ResourceSpec, tx *gorm.DB) *util.APIHandleError {
if config == nil {
return nil
}
Expand All @@ -300,7 +300,7 @@ func (s *ServiceAction) SavePluginConfig(serviceID, pluginID string, config *api
logrus.Errorf("mashal plugin config value error, %v", err)
return util.CreateAPIHandleError(500, err)
}
if err := db.GetManager().TenantPluginVersionConfigDao().AddModel(&dbmodel.TenantPluginVersionDiscoverConfig{
if err := db.GetManager().TenantPluginVersionConfigDaoTransactions(tx).AddModel(&dbmodel.TenantPluginVersionDiscoverConfig{
PluginID: pluginID,
ServiceID: serviceID,
ConfigStr: string(v),
Expand Down
Loading