Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
dc4b94d
sql-server: Add behavior: auto_gc_behavior: enable.
reltuk Feb 10, 2025
9b53d20
go: cmd: sqlserver: Fix nil SIGSEGV on AutoGCBehavior read in init.
reltuk Feb 11, 2025
62e5032
integration-tests/go-sql-server-driver: auto_gc_test.go: Tweak assert…
reltuk Feb 11, 2025
f509d98
go: sqle: auto_gc.go: Make sure the safepoint controller works on the…
reltuk Feb 12, 2025
10dfcec
[ga-format-pr] Run go/utils/repofmt/format_repo.sh and go/Godeps/upda…
reltuk Feb 12, 2025
2a47d40
go: sqle: auto_gc: Responding to PR feedback. Comments and cleanup.
reltuk Feb 14, 2025
7c9c808
Merge remote-tracking branch 'origin/main' into aaron/autogc
reltuk Feb 14, 2025
1e20b67
Merge remote-tracking branch 'origin/main' into aaron/autogc
reltuk Feb 14, 2025
20f38ca
Merge remote-tracking branch 'origin/main' into aaron/autogc
reltuk Feb 19, 2025
69630e1
go: auto_gc: Add a heuristic which allows followers in cluster replic…
reltuk Feb 19, 2025
1438933
integration-tests: go-sql-server-driver: auto_gc_test: Add a skipped …
reltuk Feb 21, 2025
efb5edc
go: sqle: auto_gc: Move to a background thread which periodically che…
reltuk Feb 21, 2025
97fd0f8
Merge remote-tracking branch 'origin/main' into aaron/autogc
reltuk Feb 21, 2025
e4a4b5d
go: store,remotesrv: Improve logging. Improve gRPC error statuses for…
reltuk Feb 21, 2025
4ce49e6
go: store/nbs: store.go: Fix GetManyCompressed to not redeliver chunk…
reltuk Feb 22, 2025
837ae43
integration-tests/go-sql-server-driver: auto_gc_test.go: Bring down a…
reltuk Feb 22, 2025
36b39df
Merge remote-tracking branch 'origin/main' into aaron/autogc
reltuk Feb 22, 2025
df99169
go: sqle/auto_gc: Add some simple tests for controller and hook.
reltuk Feb 23, 2025
7f1e9dd
[ga-format-pr] Run go/utils/repofmt/format_repo.sh and go/Godeps/upda…
reltuk Feb 23, 2025
160b434
go: sqle/auto_gc: Some PR feedback.
reltuk Feb 24, 2025
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
16 changes: 15 additions & 1 deletion go/cmd/dolt/commands/engine/sqlengine.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import (
dsqle "github.com/dolthub/dolt/go/libraries/doltcore/sqle"
dblr "github.com/dolthub/dolt/go/libraries/doltcore/sqle/binlogreplication"
"github.com/dolthub/dolt/go/libraries/doltcore/sqle/cluster"
"github.com/dolthub/dolt/go/libraries/doltcore/sqle/dprocedures"
"github.com/dolthub/dolt/go/libraries/doltcore/sqle/dsess"
"github.com/dolthub/dolt/go/libraries/doltcore/sqle/kvexec"
"github.com/dolthub/dolt/go/libraries/doltcore/sqle/mysql_file_handler"
Expand Down Expand Up @@ -80,6 +81,7 @@ type SqlEngineConfig struct {
JwksConfig []servercfg.JwksConfig
SystemVariables SystemVariables
ClusterController *cluster.Controller
AutoGCController *dsqle.AutoGCController
BinlogReplicaController binlogreplication.BinlogReplicaController
EventSchedulerStatus eventscheduler.SchedulerStatus
}
Expand Down Expand Up @@ -113,7 +115,8 @@ func NewSqlEngine(
return nil, err
}

all := dbs[:]
all := make([]dsess.SqlDatabase, len(dbs))
copy(all, dbs)
Comment thread
zachmu marked this conversation as resolved.

// this is overwritten only for server sessions
for _, db := range dbs {
Expand Down Expand Up @@ -192,6 +195,17 @@ func NewSqlEngine(
statsPro := statspro.NewProvider(pro, statsnoms.NewNomsStatsFactory(mrEnv.RemoteDialProvider()))
engine.Analyzer.Catalog.StatsProvider = statsPro

if config.AutoGCController != nil {
err = config.AutoGCController.RunBackgroundThread(bThreads, sqlEngine.NewDefaultContext)
if err != nil {
return nil, err
}
config.AutoGCController.ApplyCommitHooks(ctx, mrEnv, dbs...)
pro.InitDatabaseHooks = append(pro.InitDatabaseHooks, config.AutoGCController.InitDatabaseHook())
// XXX: We force session aware safepoint controller if auto_gc is on.
dprocedures.UseSessionAwareSafepointController = true
}

engine.Analyzer.ExecBuilder = rowexec.NewOverrideBuilder(kvexec.Builder{})
sessFactory := doltSessionFactory(pro, statsPro, mrEnv.Config(), bcController, gcSafepointController, config.Autocommit)
sqlEngine.provider = pro
Expand Down
11 changes: 11 additions & 0 deletions go/cmd/dolt/commands/sqlserver/command_line_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,10 @@ func (cfg *commandLineServerConfig) ValueSet(value string) bool {
return ok
}

func (cfg *commandLineServerConfig) AutoGCBehavior() servercfg.AutoGCBehavior {
return stubAutoGCBehavior{}
}

// DoltServerConfigReader is the default implementation of ServerConfigReader suitable for parsing Dolt config files
// and command line options.
type DoltServerConfigReader struct{}
Expand All @@ -510,3 +514,10 @@ func (d DoltServerConfigReader) ReadConfigFile(cwdFS filesys.Filesys, file strin
func (d DoltServerConfigReader) ReadConfigArgs(args *argparser.ArgParseResults, dataDirOverride string) (servercfg.ServerConfig, error) {
return NewCommandLineConfig(nil, args, dataDirOverride)
}

type stubAutoGCBehavior struct {
}

func (stubAutoGCBehavior) Enable() bool {
return false
}
11 changes: 11 additions & 0 deletions go/cmd/dolt/commands/sqlserver/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,17 @@ func ConfigureServices(
}
controller.Register(InitEventSchedulerStatus)

InitAutoGCController := &svcs.AnonService{
InitF: func(context.Context) error {
if serverConfig.AutoGCBehavior() != nil &&
serverConfig.AutoGCBehavior().Enable() {
config.AutoGCController = sqle.NewAutoGCController(lgr)
}
return nil
},
}
controller.Register(InitAutoGCController)

var sqlEngine *engine.SqlEngine
InitSqlEngine := &svcs.AnonService{
InitF: func(ctx context.Context) (err error) {
Expand Down
22 changes: 10 additions & 12 deletions go/libraries/doltcore/doltdb/doltdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -1917,23 +1917,21 @@ func (ddb *DoltDB) IsTableFileStore() bool {

// ChunkJournal returns the ChunkJournal for this DoltDB, if one is in use.
func (ddb *DoltDB) ChunkJournal() *nbs.ChunkJournal {
tableFileStore, ok := datas.ChunkStoreFromDatabase(ddb.db).(chunks.TableFileStore)
if !ok {
return nil
}
cs := datas.ChunkStoreFromDatabase(ddb.db)

generationalNbs, ok := tableFileStore.(*nbs.GenerationalNBS)
if !ok {
return nil
var store *nbs.NomsBlockStore
generationalNBS, ok := cs.(*nbs.GenerationalNBS)
if ok {
store = generationalNBS.NewGen().(*nbs.NomsBlockStore)
} else {
store = cs.(*nbs.NomsBlockStore)
}

newGen := generationalNbs.NewGen()
nbs, ok := newGen.(*nbs.NomsBlockStore)
if !ok {
if store != nil {
return store.ChunkJournal()
} else {
return nil
Comment thread
zachmu marked this conversation as resolved.
}

return nbs.ChunkJournal()
}

func (ddb *DoltDB) TableFileStoreHasJournal(ctx context.Context) (bool, error) {
Expand Down
10 changes: 10 additions & 0 deletions go/libraries/doltcore/servercfg/serverconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ const (
DefaultReadOnly = false
DefaultLogLevel = LogLevel_Info
DefaultAutoCommit = true
DefaultAutoGCBehaviorEnable = false
DefaultDoltTransactionCommit = false
DefaultMaxConnections = 100
DefaultDataDir = "."
Expand Down Expand Up @@ -198,6 +199,8 @@ type ServerConfig interface {
EventSchedulerStatus() string
// ValueSet returns whether the value string provided was explicitly set in the config
ValueSet(value string) bool
// AutoGCBehavior defines parameters around how auto-GC works for the running server.
AutoGCBehavior() AutoGCBehavior
}

// DefaultServerConfig creates a `*ServerConfig` that has all of the options set to their default values.
Expand All @@ -214,6 +217,9 @@ func defaultServerConfigYAML() *YAMLConfig {
ReadOnly: ptr(DefaultReadOnly),
AutoCommit: ptr(DefaultAutoCommit),
DoltTransactionCommit: ptr(DefaultDoltTransactionCommit),
AutoGCBehavior: &AutoGCBehaviorYAMLConfig{
Enable_: ptr(DefaultAutoGCBehaviorEnable),
},
},
UserConfig: UserYAMLConfig{
Name: ptr(""),
Expand Down Expand Up @@ -445,3 +451,7 @@ func CheckForUnixSocket(config ServerConfig) (string, bool, error) {

return "", false, nil
}

type AutoGCBehavior interface {
Enable() bool
}
28 changes: 28 additions & 0 deletions go/libraries/doltcore/servercfg/yaml_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ type BehaviorYAMLConfig struct {
DoltTransactionCommit *bool `yaml:"dolt_transaction_commit,omitempty"`

EventSchedulerStatus *string `yaml:"event_scheduler,omitempty" minver:"1.17.0"`

AutoGCBehavior *AutoGCBehaviorYAMLConfig `yaml:"auto_gc_behavior,omitempty" minver:"TBD"`
}

// UserYAMLConfig contains server configuration regarding the user account clients must use to connect
Expand Down Expand Up @@ -176,6 +178,7 @@ func YamlConfigFromFile(fs filesys.Filesys, path string) (ServerConfig, error) {

func ServerConfigAsYAMLConfig(cfg ServerConfig) *YAMLConfig {
systemVars := cfg.SystemVars()
autoGCBehavior := toAutoGCBehaviorYAML(cfg.AutoGCBehavior())
return &YAMLConfig{
LogLevelStr: ptr(string(cfg.LogLevel())),
MaxQueryLenInLogs: nillableIntPtr(cfg.MaxLoggedQueryLen()),
Expand All @@ -186,6 +189,7 @@ func ServerConfigAsYAMLConfig(cfg ServerConfig) *YAMLConfig {
DisableClientMultiStatements: ptr(cfg.DisableClientMultiStatements()),
DoltTransactionCommit: ptr(cfg.DoltTransactionCommit()),
EventSchedulerStatus: ptr(cfg.EventSchedulerStatus()),
AutoGCBehavior: autoGCBehavior,
},
ListenerConfig: ListenerYAMLConfig{
HostStr: ptr(cfg.Host()),
Expand Down Expand Up @@ -817,6 +821,13 @@ func (cfg YAMLConfig) ClusterConfig() ClusterConfig {
return cfg.ClusterCfg
}

func (cfg YAMLConfig) AutoGCBehavior() AutoGCBehavior {
if cfg.BehaviorConfig.AutoGCBehavior == nil {
return nil
}
return cfg.BehaviorConfig.AutoGCBehavior
}

func (cfg YAMLConfig) EventSchedulerStatus() string {
if cfg.BehaviorConfig.EventSchedulerStatus == nil {
return "ON"
Expand Down Expand Up @@ -922,3 +933,20 @@ func (cfg YAMLConfig) ValueSet(value string) bool {
}
return false
}

type AutoGCBehaviorYAMLConfig struct {
Enable_ *bool `yaml:"enable,omitempty" minver:"TBD"`
}

func (a *AutoGCBehaviorYAMLConfig) Enable() bool {
if a.Enable_ == nil {
return false
}
return *a.Enable_
}

func toAutoGCBehaviorYAML(a AutoGCBehavior) *AutoGCBehaviorYAMLConfig {
return &AutoGCBehaviorYAMLConfig{
Enable_: ptr(a.Enable()),
}
}
2 changes: 2 additions & 0 deletions go/libraries/doltcore/servercfg/yaml_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ behavior:
dolt_transaction_commit: true
disable_client_multi_statements: false
event_scheduler: ON
auto_gc_behavior:
enable: false

listener:
host: localhost
Expand Down
Loading