Skip to content

Commit

Permalink
server: allow configuring vmodule via cluster setting
Browse files Browse the repository at this point in the history
Closes cockroachdb#89298.

Release note: none.

Epic: none.
  • Loading branch information
dt authored and nicktrav committed Nov 4, 2022
1 parent 7046504 commit f06f760
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions pkg/server/server_sql.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ import (
"github.com/cockroachdb/cockroach/pkg/server/status"
"github.com/cockroachdb/cockroach/pkg/server/systemconfigwatcher"
"github.com/cockroachdb/cockroach/pkg/server/tracedumper"
"github.com/cockroachdb/cockroach/pkg/settings"
"github.com/cockroachdb/cockroach/pkg/settings/cluster"
"github.com/cockroachdb/cockroach/pkg/spanconfig"
"github.com/cockroachdb/cockroach/pkg/spanconfig/spanconfiglimiter"
Expand Down Expand Up @@ -344,6 +345,13 @@ type monitorAndMetricsOptions struct {
settings *cluster.Settings
}

var vmoduleSetting = settings.RegisterStringSetting(
settings.TenantWritable,
"server.debug.default_vmodule",
"vmodule string (ignored by any server with an explicit one provided at start)",
"",
)

// newRootSQLMemoryMonitor returns a started BytesMonitor and corresponding
// metrics.
func newRootSQLMemoryMonitor(opts monitorAndMetricsOptions) monitorAndMetrics {
Expand Down Expand Up @@ -1053,6 +1061,23 @@ func newSQLServer(ctx context.Context, cfg sqlServerArgs) (*SQLServer, error) {
reporter.TestingKnobs = &cfg.TestingKnobs.Server.(*TestingKnobs).DiagnosticsTestingKnobs
}

startedWithExplicitVModule := log.GetVModule() != ""
fn := func(ctx context.Context) {
if startedWithExplicitVModule {
log.Infof(ctx, "ignoring vmodule cluster setting due to starting with explicit vmodule flag")
} else {
s := vmoduleSetting.Get(&cfg.Settings.SV)
if log.GetVModule() != s {
log.Infof(ctx, "updating vmodule from cluster setting to %s", s)
if err := log.SetVModule(s); err != nil {
log.Warningf(ctx, "failed to apply vmodule cluster setting: %v", err)
}
}
}
}
vmoduleSetting.SetOnChange(&cfg.Settings.SV, fn)
fn(ctx)

var settingsWatcher *settingswatcher.SettingsWatcher
if codec.ForSystemTenant() {
settingsWatcher = settingswatcher.New(
Expand Down

0 comments on commit f06f760

Please sign in to comment.