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

server: remove contention event registry from baseStatusServer #75835

Merged
merged 1 commit into from
Feb 3, 2022
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
4 changes: 2 additions & 2 deletions pkg/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,6 @@ func NewServer(cfg Config, stopper *stop.Stopper) (*Server, error) {
sAdmin := newAdminServer(lateBoundServer, adminAuthzCheck, internalExecutor)
sHTTP := newHTTPServer(cfg)
sessionRegistry := sql.NewSessionRegistry()
contentionRegistry := contention.NewRegistry()
flowScheduler := flowinfra.NewFlowScheduler(cfg.AmbientCtx, stopper, st)

sStatus := newStatusServer(
Expand All @@ -647,10 +646,11 @@ func NewServer(cfg Config, stopper *stop.Stopper) (*Server, error) {
node.stores,
stopper,
sessionRegistry,
contentionRegistry,
flowScheduler,
internalExecutor,
)

contentionRegistry := contention.NewRegistry()
// TODO(tbg): don't pass all of Server into this to avoid this hack.
sAuth := newAuthenticationServer(lateBoundServer)
for i, gw := range []grpcGatewayServer{sAdmin, sStatus, sAuth, &sTS} {
Expand Down
33 changes: 15 additions & 18 deletions pkg/server/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,14 +135,13 @@ type baseStatusServer struct {
serverpb.UnimplementedStatusServer

log.AmbientContext
privilegeChecker *adminPrivilegeChecker
sessionRegistry *sql.SessionRegistry
contentionRegistry *contention.Registry
flowScheduler *flowinfra.FlowScheduler
st *cluster.Settings
sqlServer *SQLServer
rpcCtx *rpc.Context
stopper *stop.Stopper
privilegeChecker *adminPrivilegeChecker
sessionRegistry *sql.SessionRegistry
flowScheduler *flowinfra.FlowScheduler
st *cluster.Settings
sqlServer *SQLServer
rpcCtx *rpc.Context
stopper *stop.Stopper
}

// getLocalSessions returns a list of local sessions on this node. Note that the
Expand Down Expand Up @@ -307,7 +306,7 @@ func (b *baseStatusServer) ListLocalContentionEvents(
}

return &serverpb.ListContentionEventsResponse{
Events: b.contentionRegistry.Serialize(),
Events: b.sqlServer.execCfg.ContentionRegistry.Serialize(),
}, nil
}

Expand Down Expand Up @@ -415,21 +414,19 @@ func newStatusServer(
stores *kvserver.Stores,
stopper *stop.Stopper,
sessionRegistry *sql.SessionRegistry,
contentionRegistry *contention.Registry,
flowScheduler *flowinfra.FlowScheduler,
internalExecutor *sql.InternalExecutor,
) *statusServer {
ambient.AddLogTag("status", nil)
server := &statusServer{
baseStatusServer: &baseStatusServer{
AmbientContext: ambient,
privilegeChecker: adminAuthzCheck,
sessionRegistry: sessionRegistry,
contentionRegistry: contentionRegistry,
flowScheduler: flowScheduler,
st: st,
rpcCtx: rpcCtx,
stopper: stopper,
AmbientContext: ambient,
privilegeChecker: adminAuthzCheck,
sessionRegistry: sessionRegistry,
flowScheduler: flowScheduler,
st: st,
rpcCtx: rpcCtx,
stopper: stopper,
},
cfg: cfg,
admin: adminServer,
Expand Down
5 changes: 2 additions & 3 deletions pkg/server/tenant.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,10 @@ func StartTenant(
// the SQL server object.
tenantStatusServer := newTenantStatusServer(
baseCfg.AmbientCtx, &adminPrivilegeChecker{ie: args.circularInternalExecutor},
args.sessionRegistry, args.contentionRegistry, args.flowScheduler, baseCfg.Settings, nil,
args.sessionRegistry, args.flowScheduler, baseCfg.Settings, nil,
args.rpcContext, args.stopper,
)
args.contentionRegistry = contention.NewRegistry()
args.sqlStatusServer = tenantStatusServer
s, err := newSQLServer(ctx, args)
tenantStatusServer.sqlServer = s
Expand Down Expand Up @@ -493,7 +494,6 @@ func makeTenantSQLServerArgs(
// writing): the blob service and DistSQL.
dummyRPCServer := rpc.NewServer(rpcContext)
sessionRegistry := sql.NewSessionRegistry()
contentionRegistry := contention.NewRegistry()
flowScheduler := flowinfra.NewFlowScheduler(baseCfg.AmbientCtx, stopper, st)
return sqlServerArgs{
sqlServerOptionalKVArgs: sqlServerOptionalKVArgs{
Expand Down Expand Up @@ -529,7 +529,6 @@ func makeTenantSQLServerArgs(
registry: registry,
recorder: recorder,
sessionRegistry: sessionRegistry,
contentionRegistry: contentionRegistry,
flowScheduler: flowScheduler,
circularInternalExecutor: circularInternalExecutor,
circularJobRegistry: circularJobRegistry,
Expand Down
18 changes: 8 additions & 10 deletions pkg/server/tenant_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ func newTenantStatusServer(
ambient log.AmbientContext,
privilegeChecker *adminPrivilegeChecker,
sessionRegistry *sql.SessionRegistry,
contentionRegistry *contention.Registry,
flowScheduler *flowinfra.FlowScheduler,
st *cluster.Settings,
sqlServer *SQLServer,
Expand All @@ -87,15 +86,14 @@ func newTenantStatusServer(
ambient.AddLogTag("tenant-status", nil)
return &tenantStatusServer{
baseStatusServer: baseStatusServer{
AmbientContext: ambient,
privilegeChecker: privilegeChecker,
sessionRegistry: sessionRegistry,
contentionRegistry: contentionRegistry,
flowScheduler: flowScheduler,
st: st,
sqlServer: sqlServer,
rpcCtx: rpcCtx,
stopper: stopper,
AmbientContext: ambient,
privilegeChecker: privilegeChecker,
sessionRegistry: sessionRegistry,
flowScheduler: flowScheduler,
st: st,
sqlServer: sqlServer,
rpcCtx: rpcCtx,
stopper: stopper,
},
}
}
Expand Down