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

[pull] main from dolthub:main #46

Merged
merged 23 commits into from
Jan 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
d869c70
/go/libraries/doltcore/sqle/dsess: parallelize new sqle db stuff
coffeegoddd Jan 14, 2025
eb23dcd
/go/libraries/doltcore/sqle/dsess/autoincrement_tracker.go: wip, nil …
coffeegoddd Jan 14, 2025
fa6c12f
/go/libraries/doltcore/sqle/dsess/globalstate.go: try just changing ai
coffeegoddd Jan 14, 2025
7d54ed2
Cleaning up a couple issues missed during review
zachmu Jan 14, 2025
1514be7
[ga-bump-release] Update Dolt version to 1.45.6 and release v1.45.6
coffeegoddd Jan 14, 2025
53ba7ca
temp: add some timing logs
coffeegoddd Jan 14, 2025
4035348
/go/libraries/doltcore/sqle/dsess/globalstate.go: parallelize global …
coffeegoddd Jan 14, 2025
bff342a
/go/libraries/doltcore/sqle/dsess: remove logs
coffeegoddd Jan 14, 2025
ddecc47
/go/libraries/doltcore/sqle/dsess/globalstate.go: check for ctx error
coffeegoddd Jan 14, 2025
8c1eda8
/go/libraries/doltcore/sqle/dsess/globalstate.go: trying to fix close…
coffeegoddd Jan 14, 2025
d05b6a8
Don't panic when attempting to update workspace table (#8742)
macneale4 Jan 14, 2025
a819aa2
/go/libraries/doltcore/sqle/dsess/globalstate.go: fix again
coffeegoddd Jan 14, 2025
489e08b
Tweaked a few settings to get the default output behavior we want
zachmu Jan 14, 2025
5144868
[ga-format-pr] Run go/utils/repofmt/format_repo.sh and go/Godeps/upda…
zachmu Jan 14, 2025
93355c5
/go/libraries/doltcore/sqle/dsess/globalstate.go: pr feedback
coffeegoddd Jan 14, 2025
61f6ce3
Fix minver issues
zachmu Jan 14, 2025
a6c9e8b
Merge upstream
zachmu Jan 14, 2025
99c7cca
Merge pull request #8740 from dolthub/db/parallelize
coffeegoddd Jan 14, 2025
e43c01c
Fixed test data
zachmu Jan 14, 2025
17c65a7
Allow `dolt sql` command line access to always log in as the root sup…
fulghum Jan 14, 2025
6392c11
Merge pull request #8743 from dolthub/zachmu/fix-yaml-bug
zachmu Jan 14, 2025
de95062
Add --prune option to dolt_pull procedure (#8745)
macneale4 Jan 14, 2025
cabf880
Merge pull request #8746 from dolthub/fulghum/sql_shell_root_access
fulghum Jan 14, 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
1 change: 1 addition & 0 deletions go/cmd/dolt/cli/arg_parser_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ func CreatePullArgParser() *argparser.ArgParser {
ap.SupportsFlag(NoCommitFlag, "", "Perform the merge and stop just before creating a merge commit. Note this will not prevent a fast-forward merge; use the --no-ff arg together with the --no-commit arg to prevent both fast-forwards and merge commits.")
ap.SupportsFlag(NoEditFlag, "", "Use an auto-generated commit message when creating a merge commit. The default for interactive CLI sessions is to open an editor.")
ap.SupportsString(UserFlag, "", "user", "User name to use when authenticating with the remote. Gets password from the environment variable {{.EmphasisLeft}}DOLT_REMOTE_PASSWORD{{.EmphasisRight}}.")
ap.SupportsFlag(PruneFlag, "p", "After fetching, remove any remote-tracking references that don't exist on the remote.")
ap.SupportsFlag(SilentFlag, "", "Suppress progress information.")
return ap
}
Expand Down
3 changes: 3 additions & 0 deletions go/cmd/dolt/commands/pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,9 @@ func constructInterpolatedDoltPullQuery(apr *argparser.ArgParseResults) (string,
if apr.Contains(cli.NoEditFlag) {
args = append(args, "'--no-edit'")
}
if apr.Contains(cli.PruneFlag) {
args = append(args, "'--prune'")
}
if user, hasUser := apr.GetValue(cli.UserFlag); hasUser {
args = append(args, "'--user'")
args = append(args, "?")
Expand Down
13 changes: 1 addition & 12 deletions go/cmd/dolt/commands/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -287,20 +287,9 @@ func newLateBindingEngine(
}

} else {
// Ensure a root user exists, with superuser privs
dbUser = DefaultUser
ed := rawDb.Editor()
user := rawDb.GetUser(ed, dbUser, config.ServerHost, false)
ed.Close()
if user != nil {
// Want to ensure that the user has an empty password. If it has a password, we'll error
err := passwordValidate(rawDb, salt, dbUser, nil)
if err != nil {
return nil, nil, nil, err
}
}

// If the user doesn't exist, we'll create it with superuser privs.
ed = rawDb.Editor()
defer ed.Close()
rawDb.AddSuperUser(ed, dbUser, config.ServerHost, "")
}
Expand Down
2 changes: 1 addition & 1 deletion go/cmd/dolt/doltversion/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@
package doltversion

const (
Version = "1.45.5"
Version = "1.45.6"
)
10 changes: 7 additions & 3 deletions go/libraries/doltcore/servercfg/testdata/minver_validation.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,18 @@ RemotesapiConfig servercfg.RemotesapiYAMLConfig 0.0.0 remotesapi,omitempty
-ReadOnly_ *bool 1.30.5 read_only,omitempty
PrivilegeFile *string 0.0.0 privilege_file,omitempty
BranchControlFile *string 0.0.0 branch_control_file,omitempty
Vars []servercfg.UserSessionVars 0.0.0 user_session_vars,omitempty
Vars []servercfg.UserSessionVars 0.0.0 user_session_vars
-Name string 0.0.0 name
-Vars map[string]interface{} 0.0.0 vars
SystemVars_ map[string]interface{} 1.11.1 system_variables,omitempty
Jwks *[]servercfg.JwksConfig 0.0.0 jwks,omitempty
Jwks []servercfg.JwksConfig 0.0.0 jwks
-Name string 0.0.0 name
-LocationUrl string 0.0.0 location_url
-Claims map[string]string 0.0.0 claims
-FieldsToLog []string 0.0.0 fields_to_log
GoldenMysqlConn *string 0.0.0 golden_mysql_conn,omitempty
MetricsConfig servercfg.MetricsYAMLConfig 0.0.0 metrics,omitempty
-Labels *map[string]string 0.0.0 labels,omitempty
-Labels map[string]string 0.0.0 labels
-Host *string 0.0.0 host,omitempty
-Port *int 0.0.0 port,omitempty
ClusterCfg *servercfg.ClusterYAMLConfig 0.0.0 cluster,omitempty
Expand Down
48 changes: 17 additions & 31 deletions go/libraries/doltcore/servercfg/yaml_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,20 +47,6 @@ func nillableIntPtr(n int) *int {
return &n
}

func nillableSlicePtr[T any](s []T) *[]T {
if len(s) == 0 {
return nil
}
return &s
}

func nillableMapPtr[K comparable, V any](m map[K]V) *map[K]V {
if len(m) == 0 {
return nil
}
return &m
}

// BehaviorYAMLConfig contains server configuration regarding how the server should behave
type BehaviorYAMLConfig struct {
ReadOnly *bool `yaml:"read_only,omitempty"`
Expand Down Expand Up @@ -113,9 +99,9 @@ type PerformanceYAMLConfig struct {
}

type MetricsYAMLConfig struct {
Labels *map[string]string `yaml:"labels,omitempty"`
Host *string `yaml:"host,omitempty"`
Port *int `yaml:"port,omitempty"`
Labels map[string]string `yaml:"labels"`
Host *string `yaml:"host,omitempty"`
Port *int `yaml:"port,omitempty"`
}

type RemotesapiYAMLConfig struct {
Expand Down Expand Up @@ -151,9 +137,9 @@ type YAMLConfig struct {
PrivilegeFile *string `yaml:"privilege_file,omitempty"`
BranchControlFile *string `yaml:"branch_control_file,omitempty"`
// TODO: Rename to UserVars_
Vars []UserSessionVars `yaml:"user_session_vars,omitempty"`
Vars []UserSessionVars `yaml:"user_session_vars"`
SystemVars_ map[string]interface{} `yaml:"system_variables,omitempty" minver:"1.11.1"`
Jwks *[]JwksConfig `yaml:"jwks,omitempty"`
Jwks []JwksConfig `yaml:"jwks"`
GoldenMysqlConn *string `yaml:"golden_mysql_conn,omitempty"`
MetricsConfig MetricsYAMLConfig `yaml:"metrics,omitempty"`
ClusterCfg *ClusterYAMLConfig `yaml:"cluster,omitempty"`
Expand Down Expand Up @@ -220,7 +206,7 @@ func ServerConfigAsYAMLConfig(cfg ServerConfig) *YAMLConfig {
DataDirStr: ptr(cfg.DataDir()),
CfgDirStr: ptr(cfg.CfgDir()),
MetricsConfig: MetricsYAMLConfig{
Labels: nillableMapPtr(cfg.MetricsLabels()),
Labels: cfg.MetricsLabels(),
Host: nillableStrPtr(cfg.MetricsHost()),
Port: ptr(cfg.MetricsPort()),
},
Expand All @@ -233,7 +219,7 @@ func ServerConfigAsYAMLConfig(cfg ServerConfig) *YAMLConfig {
BranchControlFile: ptr(cfg.BranchControlFilePath()),
SystemVars_: systemVars,
Vars: cfg.UserVars(),
Jwks: nillableSlicePtr(cfg.JwksConfig()),
Jwks: cfg.JwksConfig(),
}
}

Expand Down Expand Up @@ -293,7 +279,7 @@ func ServerConfigSetValuesAsYAMLConfig(cfg ServerConfig) *YAMLConfig {
DataDirStr: zeroIf(ptr(cfg.DataDir()), !cfg.ValueSet(DataDirKey)),
CfgDirStr: zeroIf(ptr(cfg.CfgDir()), !cfg.ValueSet(CfgDirKey)),
MetricsConfig: MetricsYAMLConfig{
Labels: zeroIf(ptr(cfg.MetricsLabels()), !cfg.ValueSet(MetricsLabelsKey)),
Labels: zeroIf(cfg.MetricsLabels(), !cfg.ValueSet(MetricsLabelsKey)),
Host: zeroIf(ptr(cfg.MetricsHost()), !cfg.ValueSet(MetricsHostKey)),
Port: zeroIf(ptr(cfg.MetricsPort()), !cfg.ValueSet(MetricsPortKey)),
},
Expand All @@ -306,7 +292,7 @@ func ServerConfigSetValuesAsYAMLConfig(cfg ServerConfig) *YAMLConfig {
BranchControlFile: zeroIf(ptr(cfg.BranchControlFilePath()), !cfg.ValueSet(BranchControlFilePathKey)),
SystemVars_: zeroIf(systemVars, !cfg.ValueSet(SystemVarsKey)),
Vars: zeroIf(cfg.UserVars(), !cfg.ValueSet(UserVarsKey)),
Jwks: zeroIf(ptr(cfg.JwksConfig()), !cfg.ValueSet(JwksConfigKey)),
Jwks: zeroIf(cfg.JwksConfig(), !cfg.ValueSet(JwksConfigKey)),
}
}

Expand Down Expand Up @@ -388,7 +374,7 @@ func (cfg YAMLConfig) withPlaceholdersFilledIn() YAMLConfig {
}

if withPlaceholders.MetricsConfig.Labels == nil {
withPlaceholders.MetricsConfig.Labels = &map[string]string{}
withPlaceholders.MetricsConfig.Labels = map[string]string{}
}
if withPlaceholders.MetricsConfig.Host == nil {
withPlaceholders.MetricsConfig.Host = ptr("localhost")
Expand All @@ -407,11 +393,11 @@ func (cfg YAMLConfig) withPlaceholdersFilledIn() YAMLConfig {
if withPlaceholders.ClusterCfg == nil {
withPlaceholders.ClusterCfg = &ClusterYAMLConfig{
StandbyRemotes_: []StandbyRemoteYAMLConfig{
StandbyRemoteYAMLConfig{
{
Name_: "standby_replica_one",
RemoteURLTemplate_: "https://standby_replica_one.svc.cluster.local:50051/{database}",
},
StandbyRemoteYAMLConfig{
{
Name_: "standby_replica_two",
RemoteURLTemplate_: "https://standby_replica_two.svc.cluster.local:50051/{database}",
},
Expand All @@ -438,7 +424,7 @@ func (cfg YAMLConfig) withPlaceholdersFilledIn() YAMLConfig {

if withPlaceholders.Vars == nil {
withPlaceholders.Vars = []UserSessionVars{
UserSessionVars{
{
Name: "root",
Vars: map[string]interface{}{
"dolt_show_system_tables": 1,
Expand All @@ -455,8 +441,8 @@ func (cfg YAMLConfig) withPlaceholdersFilledIn() YAMLConfig {
}
}

if withPlaceholders.Jwks == nil {
withPlaceholders.Jwks = &[]JwksConfig{}
if len(withPlaceholders.Jwks) == 0 {
withPlaceholders.Jwks = []JwksConfig{}
}

return withPlaceholders
Expand Down Expand Up @@ -675,7 +661,7 @@ func (cfg YAMLConfig) DisableClientMultiStatements() bool {
// MetricsLabels returns labels that are applied to all prometheus metrics
func (cfg YAMLConfig) MetricsLabels() map[string]string {
if cfg.MetricsConfig.Labels != nil {
return *cfg.MetricsConfig.Labels
return cfg.MetricsConfig.Labels
}
return nil
}
Expand Down Expand Up @@ -744,7 +730,7 @@ func (cfg YAMLConfig) SystemVars() map[string]interface{} {
// wksConfig is JSON Web Key Set config, and used to validate a user authed with a jwt (JSON Web Token).
func (cfg YAMLConfig) JwksConfig() []JwksConfig {
if cfg.Jwks != nil {
return *cfg.Jwks
return cfg.Jwks
}
return nil
}
Expand Down
6 changes: 3 additions & 3 deletions go/libraries/doltcore/servercfg/yaml_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ jwks:
expected.MetricsConfig = MetricsYAMLConfig{
Host: ptr("123.45.67.89"),
Port: ptr(9091),
Labels: &map[string]string{
Labels: map[string]string{
"label1": "value1",
"label2": "2",
"label3": "true",
Expand All @@ -121,7 +121,7 @@ jwks:
},
},
}
expected.Jwks = &[]JwksConfig{
expected.Jwks = []JwksConfig{
{
Name: "jwks_name",
LocationUrl: "https://website.com",
Expand Down Expand Up @@ -461,7 +461,7 @@ func TestYAMLConfigVerboseStringEquivalent(t *testing.T) {
},
YAMLConfig{
MetricsConfig: MetricsYAMLConfig{
Labels: &map[string]string{
Labels: map[string]string{
"xyz": "123",
"0": "AAABBB",
},
Expand Down
15 changes: 8 additions & 7 deletions go/libraries/doltcore/sqle/dprocedures/dolt_pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,7 @@ func doDoltPull(ctx *sql.Context, args []string) (int, int, string, error) {
return noConflictsOrViolations, threeWayMerge, "", err
}

// Fetch all references
branchRefs, err := srcDB.GetHeadRefs(ctx)
if err != nil {
return noConflictsOrViolations, threeWayMerge, "", fmt.Errorf("%w: %s", env.ErrFailedToReadDb, err.Error())
}

// Assert the branch exists
_, hasBranch, err := srcDB.HasBranch(ctx, pullSpec.Branch.GetPath())
if err != nil {
return noConflictsOrViolations, threeWayMerge, "", err
Expand All @@ -152,7 +147,13 @@ func doDoltPull(ctx *sql.Context, args []string) (int, int, string, error) {
fmt.Errorf("branch %q not found on remote", pullSpec.Branch.GetPath())
}

mode := ref.UpdateMode{Force: true, Prune: false}
// Fetch all references
branchRefs, err := srcDB.GetHeadRefs(ctx)
if err != nil {
return noConflictsOrViolations, threeWayMerge, "", fmt.Errorf("%w: %s", env.ErrFailedToReadDb, err.Error())
}
prune := apr.Contains(cli.PruneFlag)
mode := ref.UpdateMode{Force: true, Prune: prune}
err = actions.FetchRefSpecs(ctx, dbData, srcDB, pullSpec.RefSpecs, false, &pullSpec.Remote, mode, runProgFuncs, stopProgFuncs)
if err != nil {
return noConflictsOrViolations, threeWayMerge, "", fmt.Errorf("fetch failed: %w", err)
Expand Down
48 changes: 27 additions & 21 deletions go/libraries/doltcore/sqle/dsess/autoincrement_tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (

"github.com/dolthub/go-mysql-server/sql"
gmstypes "github.com/dolthub/go-mysql-server/sql/types"
"golang.org/x/sync/errgroup"

"github.com/dolthub/dolt/go/libraries/doltcore/doltdb"
"github.com/dolthub/dolt/go/libraries/doltcore/doltdb/durable"
Expand Down Expand Up @@ -398,34 +399,39 @@ func (a *AutoIncrementTracker) AcquireTableLock(ctx *sql.Context, tableName stri
}

func (a *AutoIncrementTracker) InitWithRoots(ctx context.Context, roots ...doltdb.Rootish) error {
for _, root := range roots {
r, err := root.ResolveRootValue(ctx)
if err != nil {
return err
}
eg, egCtx := errgroup.WithContext(ctx)
eg.SetLimit(128)

err = r.IterTables(ctx, func(tableName doltdb.TableName, table *doltdb.Table, sch schema.Schema) (bool, error) {
if !schema.HasAutoIncrement(sch) {
return false, nil
for _, root := range roots {
eg.Go(func() error {
if egCtx.Err() != nil {
return egCtx.Err()
}

seq, err := table.GetAutoIncrementValue(ctx)
if err != nil {
return true, err
r, rerr := root.ResolveRootValue(egCtx)
if rerr != nil {
return rerr
}

tableNameStr := tableName.ToLower().Name
if oldValue, loaded := a.sequences.LoadOrStore(tableNameStr, seq); loaded && seq > oldValue.(uint64) {
a.sequences.Store(tableNameStr, seq)
}
return r.IterTables(egCtx, func(tableName doltdb.TableName, table *doltdb.Table, sch schema.Schema) (bool, error) {
if !schema.HasAutoIncrement(sch) {
return false, nil
}

return false, nil
})
seq, iErr := table.GetAutoIncrementValue(egCtx)
if iErr != nil {
return true, iErr
}

if err != nil {
return err
}
tableNameStr := tableName.ToLower().Name
if oldValue, loaded := a.sequences.LoadOrStore(tableNameStr, seq); loaded && seq > oldValue.(uint64) {
a.sequences.Store(tableNameStr, seq)
}

return false, nil
})
})
}

return nil
return eg.Wait()
}
Loading
Loading