mirror of
https://github.com/dolthub/dolt.git
synced 2026-02-27 00:51:39 -06:00
Account for nil AutoGCBehavior object to indicate default behavior
This commit is contained in:
@@ -271,12 +271,14 @@ func ConfigureServices(
|
||||
|
||||
InitAutoGCController := &svcs.AnonService{
|
||||
InitF: func(context.Context) error {
|
||||
if cfg.ServerConfig.AutoGCBehavior() != nil && cfg.ServerConfig.AutoGCBehavior().Enable() {
|
||||
// Having AutoGCBehavior == nil means that they are using default behavior, which is enabled.
|
||||
if cfg.ServerConfig.AutoGCBehavior() == nil {
|
||||
config.AutoGCController = sqle.NewAutoGCController(chunks.SimpleArchive, lgr)
|
||||
} else if cfg.ServerConfig.AutoGCBehavior().Enable() {
|
||||
cmp := chunks.GCArchiveLevel(cfg.ServerConfig.AutoGCBehavior().ArchiveLevel())
|
||||
if cmp < chunks.NoArchive || cmp > chunks.MaxArchiveLevel {
|
||||
return fmt.Errorf("invalid value for %s: %d", cli.ArchiveLevelParam, cmp)
|
||||
}
|
||||
|
||||
config.AutoGCController = sqle.NewAutoGCController(cmp, lgr)
|
||||
}
|
||||
return nil
|
||||
|
||||
@@ -284,7 +284,7 @@ tests:
|
||||
result:
|
||||
columns: ["@@GLOBAL.dolt_log_level"]
|
||||
rows: [["info"]]
|
||||
- name: "@@global.dolt_auto_gc_enabled false"
|
||||
- name: "@@global.dolt_auto_gc_enabled default"
|
||||
repos:
|
||||
- name: repo1
|
||||
server:
|
||||
@@ -296,8 +296,8 @@ tests:
|
||||
- query: "select @@GLOBAL.dolt_auto_gc_enabled"
|
||||
result:
|
||||
columns: ["@@GLOBAL.dolt_auto_gc_enabled"]
|
||||
rows: [[0]]
|
||||
- exec: "SET @@GLOBAL.dolt_auto_gc_enabled = 1"
|
||||
rows: [[1]]
|
||||
- exec: "SET @@GLOBAL.dolt_auto_gc_enabled = 0"
|
||||
error_match: "Variable 'dolt_auto_gc_enabled' is a read only variable"
|
||||
- name: "@@global.dolt_auto_gc_enabled true"
|
||||
repos:
|
||||
@@ -320,6 +320,27 @@ tests:
|
||||
result:
|
||||
columns: ["@@GLOBAL.dolt_auto_gc_enabled"]
|
||||
rows: [[1]]
|
||||
- name: "@@global.dolt_auto_gc_enabled false"
|
||||
repos:
|
||||
- name: repo1
|
||||
with_files:
|
||||
- name: "config.yaml"
|
||||
contents: |
|
||||
behavior:
|
||||
auto_gc_behavior:
|
||||
enable: false
|
||||
listener:
|
||||
port: {{get_port "repo1"}}
|
||||
server:
|
||||
args: ["--config", "config.yaml"]
|
||||
dynamic_port: repo1
|
||||
connections:
|
||||
- on: repo1
|
||||
queries:
|
||||
- query: "select @@GLOBAL.dolt_auto_gc_enabled"
|
||||
result:
|
||||
columns: ["@@GLOBAL.dolt_auto_gc_enabled"]
|
||||
rows: [[0]]
|
||||
- name: system variables in config.yaml can be read in show variables
|
||||
repos:
|
||||
- name: repo1
|
||||
|
||||
Reference in New Issue
Block a user