Skip to content

Commit

Permalink
server: lift jobAdoptionStopFile declaration out of SQL server
Browse files Browse the repository at this point in the history
It's declared using the Stores, which we don't want the SQL server to
have to think about.

Release note: None
  • Loading branch information
tbg committed May 28, 2020
1 parent 15034ae commit dab29d9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
9 changes: 9 additions & 0 deletions pkg/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,14 @@ func NewServer(cfg Config, stopper *stop.Stopper) (*Server, error) {
gw.RegisterService(grpcServer.Server)
}

var jobAdoptionStopFile string
for _, spec := range cfg.Stores.Specs {
if !spec.InMemory && spec.Path != "" {
jobAdoptionStopFile = filepath.Join(spec.Path, jobs.PreventAdoptionFile)
break
}
}

sqlServer, err := newSQLServer(ctx, sqlServerArgs{
sqlServerOptionalArgs: sqlServerOptionalArgs{
rpcContext: rpcContext,
Expand Down Expand Up @@ -549,6 +557,7 @@ func NewServer(cfg Config, stopper *stop.Stopper) (*Server, error) {
sessionRegistry: sessionRegistry,
circularInternalExecutor: internalExecutor,
jobRegistry: jobRegistry,
jobAdoptionStopFile: jobAdoptionStopFile,
protectedtsProvider: protectedtsProvider,
})
if err != nil {
Expand Down
13 changes: 3 additions & 10 deletions pkg/server/server_sql.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,8 @@ type sqlServerArgs struct {
// The protected timestamps KV subsystem depends on this, so we pass a
// pointer to an empty struct in this configuration, which newSQLServer
// fills.
jobRegistry *jobs.Registry
jobRegistry *jobs.Registry
jobAdoptionStopFile string

// The executorConfig uses the provider.
protectedtsProvider protectedts.Provider
Expand All @@ -174,14 +175,6 @@ func newSQLServer(ctx context.Context, cfg sqlServerArgs) (*sqlServer, error) {
execCfg := &sql.ExecutorConfig{}
codec := keys.MakeSQLCodec(cfg.tenantID)

var jobAdoptionStopFile string
for _, spec := range cfg.Stores.Specs {
if !spec.InMemory && spec.Path != "" {
jobAdoptionStopFile = filepath.Join(spec.Path, jobs.PreventAdoptionFile)
break
}
}

// Create blob service for inter-node file sharing.
blobService, err := blobs.NewBlobService(cfg.Settings.ExternalIODir)
if err != nil {
Expand Down Expand Up @@ -211,7 +204,7 @@ func newSQLServer(ctx context.Context, cfg sqlServerArgs) (*sqlServer, error) {
// in sql/jobs/registry.go on planHookMaker.
return sql.NewInternalPlanner(opName, nil, user, &sql.MemoryMetrics{}, execCfg)
},
jobAdoptionStopFile,
cfg.jobAdoptionStopFile,
)
}
cfg.registry.AddMetricStruct(jobRegistry.MetricsStruct())
Expand Down

0 comments on commit dab29d9

Please sign in to comment.