Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
fix: data race Former-commit-id: 32083c596fa35b7a2de3f08f745bdac40dbf5a72 Former-commit-id: 06c85647d2f9fe4636b6509b89a883b57c96f0e2
p0ny3fd9eea478b1
diff --git a/backend/api/auth/auth.go b/backend/api/auth/auth.goindex b62315302c..0c228fe1ec 100644--- a/backend/api/auth/auth.go+++ b/backend/api/auth/auth.go@@ -204,7 +204,7 @@ func (in *APIAuthInterceptor) getPrincipalID(ctx context.Context, accessTokenStr}// Only update for authorized request.- in.profile.LastActiveTS = time.Now().Unix()+ in.profile.LastActiveTS.Store(time.Now().Unix())return principalID, nil}diff --git a/backend/api/v1/actuator_service.go b/backend/api/v1/actuator_service.goindex 30fb6618f1..5b16fdf303 100644--- a/backend/api/v1/actuator_service.go+++ b/backend/api/v1/actuator_service.go@@ -296,7 +296,7 @@ func (s *ActuatorService) getServerInfo(ctx context.Context) (*v1pb.ActuatorInfoExternalUrl: setting.ExternalUrl,DisallowSignup: setting.DisallowSignup,Require_2Fa: setting.Require_2Fa,- LastActiveTime: timestamppb.New(time.Unix(s.profile.LastActiveTS, 0)),+ LastActiveTime: timestamppb.New(time.Unix(s.profile.LastActiveTS.Load(), 0)),WorkspaceId: workspaceID,Debug: s.profile.RuntimeDebug.Load(),Docker: s.profile.IsDocker,diff --git a/backend/bin/server/cmd/profile.go b/backend/bin/server/cmd/profile.goindex 5fb6d9292d..fd4ffb0cfd 100644--- a/backend/bin/server/cmd/profile.go+++ b/backend/bin/server/cmd/profile.go@@ -31,9 +31,9 @@ func getBaseProfile(dataDir string) *config.Profile {GitCommit: gitcommit,PgURL: flags.pgURL,DeployID: uuid.NewString()[:8],- LastActiveTS: time.Now().Unix(),}+ config.LastActiveTS.Store(time.Now().Unix())config.RuntimeDebug.Store(flags.debug)config.RuntimeMemoryProfileThreshold.Store(flags.memoryProfileThreshold)return configdiff --git a/backend/component/config/profile.go b/backend/component/config/profile.goindex c6a1f57e60..0b5023d46e 100644--- a/backend/component/config/profile.go+++ b/backend/component/config/profile.go@@ -44,7 +44,7 @@ type Profile struct {MetricConnectionKey string// LastActiveTS is the service last active timestamp, any API calls will refresh this value.- LastActiveTS int64+ LastActiveTS atomic.Int64// Unique ID per Bytebase instance run.DeployID string// Whether the server is running in a docker container.diff --git a/backend/runner/metricreport/reporter.go b/backend/runner/metricreport/reporter.goindex da965f8224..637b406d25 100644--- a/backend/runner/metricreport/reporter.go+++ b/backend/runner/metricreport/reporter.go@@ -196,7 +196,7 @@ func (m *Reporter) identify(ctx context.Context) (string, error) {identifyTraitForOrgID: orgID,identifyTraitForOrgName: orgName,identifyTraitForMode: mode,- identifyTraitForLastActiveTime: time.Unix(m.profile.LastActiveTS, 0).String(),+ identifyTraitForLastActiveTime: time.Unix(m.profile.LastActiveTS.Load(), 0).String(),identifyTraitForSubscriptionStartDate: subscriptionStartDate,identifyTraitForSubscriptionEndDate: subscriptionEndDate,},