From 7927c0790ef2a9683729c1efbf2312e396a9398f Mon Sep 17 00:00:00 2001 From: Zach Musgrave Date: Thu, 25 May 2023 15:37:36 -0700 Subject: [PATCH 1/8] Made errors in replication config never prevent server startup --- go/cmd/dolt/commands/engine/utils.go | 24 ++++--------------- .../doltcore/sqle/read_replica_database.go | 6 +++-- go/libraries/doltcore/sqle/replication.go | 9 ++++--- 3 files changed, 14 insertions(+), 25 deletions(-) diff --git a/go/cmd/dolt/commands/engine/utils.go b/go/cmd/dolt/commands/engine/utils.go index 1f549adaf9..12e482da56 100644 --- a/go/cmd/dolt/commands/engine/utils.go +++ b/go/cmd/dolt/commands/engine/utils.go @@ -18,8 +18,6 @@ import ( "context" "fmt" - "github.com/dolthub/go-mysql-server/sql" - "github.com/dolthub/dolt/go/cmd/dolt/cli" "github.com/dolthub/dolt/go/libraries/doltcore/doltdb" "github.com/dolthub/dolt/go/libraries/doltcore/env" @@ -28,6 +26,7 @@ import ( "github.com/dolthub/dolt/go/libraries/doltcore/table/editor" "github.com/dolthub/dolt/go/libraries/utils/filesys" "github.com/dolthub/dolt/go/store/types" + "github.com/dolthub/go-mysql-server/sql" ) // CollectDBs takes a MultiRepoEnv and creates Database objects from each environment and returns a slice of these @@ -49,17 +48,6 @@ func CollectDBs(ctx context.Context, mrEnv *env.MultiRepoEnv, useBulkEditor bool return false, err } - if _, remote, ok := sql.SystemVariables.GetGlobal(dsess.ReadReplicaRemote); ok && remote != "" { - remoteName, ok := remote.(string) - if !ok { - return true, sql.ErrInvalidSystemVariableValue.New(remote) - } - db, err = newReplicaDatabase(ctx, name, remoteName, dEnv) - if err != nil { - return true, err - } - } - dbs = append(dbs, db) locations = append(locations, dEnv.FS) @@ -110,9 +98,8 @@ func newDatabase(ctx context.Context, name string, dEnv *env.DoltEnv, useBulkEdi return sqle.NewDatabase(ctx, name, dEnv.DbData(), opts) } -// newReplicaDatabase creates a new dsqle.ReadReplicaDatabase. If the doltdb.SkipReplicationErrorsKey global variable is set, -// skip errors related to database construction only and return a partially functional dsqle.ReadReplicaDatabase -// that will log warnings when attempting to perform replica commands. +// newReplicaDatabase creates a new dsqle.ReadReplicaDatabase. In the case of an invalid configuration, returns an +// error along with a partially constructed database. func newReplicaDatabase(ctx context.Context, name string, remoteName string, dEnv *env.DoltEnv) (sqle.ReadReplicaDatabase, error) { tmpDir, err := dEnv.TempTableFilesDir() if err != nil { @@ -131,11 +118,8 @@ func newReplicaDatabase(ctx context.Context, name string, remoteName string, dEn rrd, err := sqle.NewReadReplicaDatabase(ctx, db, remoteName, dEnv) if err != nil { err = fmt.Errorf("%w from remote '%s'; %s", sqle.ErrFailedToLoadReplicaDB, remoteName, err.Error()) - if !dsess.IgnoreReplicationErrors() { - return sqle.ReadReplicaDatabase{}, err - } cli.Println(err) - return sqle.ReadReplicaDatabase{Database: db}, nil + return sqle.ReadReplicaDatabase{Database: db}, err } return rrd, nil } diff --git a/go/libraries/doltcore/sqle/read_replica_database.go b/go/libraries/doltcore/sqle/read_replica_database.go index 1cb591e3ef..fc4b3485ca 100644 --- a/go/libraries/doltcore/sqle/read_replica_database.go +++ b/go/libraries/doltcore/sqle/read_replica_database.go @@ -143,7 +143,8 @@ func (rrd ReadReplicaDatabase) PullFromRemote(ctx *sql.Context) error { switch { case headsArg != "" && allHeads == dsess.SysVarTrue: - return fmt.Errorf("%w; cannot set both 'dolt_replicate_heads' and 'dolt_replicate_all_heads'", ErrInvalidReplicateHeadsSetting) + ctx.GetLogger().Warnf("cannot set both @@dolt_replicate_heads and @@dolt_replicate_all_heads, replication disabled") + return nil case headsArg != "": heads, ok := headsArg.(string) if !ok { @@ -210,7 +211,8 @@ func (rrd ReadReplicaDatabase) PullFromRemote(ctx *sql.Context) error { return nil } default: - return fmt.Errorf("%w: dolt_replicate_heads not set", ErrInvalidReplicateHeadsSetting) + ctx.GetLogger().Warnf("must set either @@dolt_replicate_heads or @@dolt_replicate_all_heads, replication disabled") + return nil } return nil diff --git a/go/libraries/doltcore/sqle/replication.go b/go/libraries/doltcore/sqle/replication.go index ae11b1e35e..cb2191c76f 100644 --- a/go/libraries/doltcore/sqle/replication.go +++ b/go/libraries/doltcore/sqle/replication.go @@ -20,6 +20,7 @@ import ( "io" "github.com/dolthub/go-mysql-server/sql" + "github.com/sirupsen/logrus" "github.com/dolthub/dolt/go/cmd/dolt/cli" "github.com/dolthub/dolt/go/libraries/doltcore/doltdb" @@ -135,9 +136,11 @@ func ApplyReplicationConfig(ctx context.Context, bThreads *sql.BackgroundThreads if !ok { return nil, sql.ErrInvalidSystemVariableValue.New(remote) } - db, err = newReplicaDatabase(ctx, db.Name(), remoteName, dEnv) - if err != nil { - return nil, err + rdb, err := newReplicaDatabase(ctx, db.Name(), remoteName, dEnv) + if err == nil { + db = rdb + } else { + logrus.Errorf("invalid replication configuration, replication disabled: %v", err) } } From f01a5e00689fb3e6089bbee6a49dc0c0eb3c9a82 Mon Sep 17 00:00:00 2001 From: Zach Musgrave Date: Thu, 25 May 2023 15:56:05 -0700 Subject: [PATCH 2/8] New bats test for replication errors --- integration-tests/bats/replication.bats | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/integration-tests/bats/replication.bats b/integration-tests/bats/replication.bats index 2cf0d2cb57..2cafd4ff66 100644 --- a/integration-tests/bats/replication.bats +++ b/integration-tests/bats/replication.bats @@ -23,6 +23,31 @@ teardown() { cd $BATS_TMPDIR } +@test "replication: configuration errors" { + cd repo1 + dolt sql -q "SET @@persist.dolt_read_replica_remote = 'doesNotExist';" + + run dolt sql -q "show tables" + [ "$status" -eq 0 ] + [[ "$output" =~ "replication disabled" ]] || false + + dolt sql -q "SET @@persist.dolt_read_replica_remote = 'remote1';" + run dolt sql -q "show tables" + [ "$status" -eq 0 ] + [[ "$output" =~ "replication disabled" ]] || false + + dolt sql -q "SET @@persist.dolt_replicate_all_heads = 1"; + dolt sql -q "SET @@persist.dolt_replicate_heads = 'main';"; + run dolt sql -q "show tables" + [ "$status" -eq 0 ] + [[ "$output" =~ "replication disabled" ]] || false + + dolt sql -q "SET @@persist.dolt_replicate_heads = '';"; + run dolt sql -q "show tables" + [ "$status" -eq 0 ] + [[ ! "$output" =~ "replication disabled" ]] || false +} + @test "replication: default no replication" { cd repo1 dolt sql -q "create table t1 (a int primary key)" From d4af2d264a04a137bb3105eebe6ad2155bb47a18 Mon Sep 17 00:00:00 2001 From: zachmu Date: Thu, 25 May 2023 23:05:48 +0000 Subject: [PATCH 3/8] [ga-format-pr] Run go/utils/repofmt/format_repo.sh and go/Godeps/update.sh --- go/cmd/dolt/commands/engine/utils.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/go/cmd/dolt/commands/engine/utils.go b/go/cmd/dolt/commands/engine/utils.go index 12e482da56..94412e69c4 100644 --- a/go/cmd/dolt/commands/engine/utils.go +++ b/go/cmd/dolt/commands/engine/utils.go @@ -18,6 +18,8 @@ import ( "context" "fmt" + "github.com/dolthub/go-mysql-server/sql" + "github.com/dolthub/dolt/go/cmd/dolt/cli" "github.com/dolthub/dolt/go/libraries/doltcore/doltdb" "github.com/dolthub/dolt/go/libraries/doltcore/env" @@ -26,7 +28,6 @@ import ( "github.com/dolthub/dolt/go/libraries/doltcore/table/editor" "github.com/dolthub/dolt/go/libraries/utils/filesys" "github.com/dolthub/dolt/go/store/types" - "github.com/dolthub/go-mysql-server/sql" ) // CollectDBs takes a MultiRepoEnv and creates Database objects from each environment and returns a slice of these @@ -98,7 +99,7 @@ func newDatabase(ctx context.Context, name string, dEnv *env.DoltEnv, useBulkEdi return sqle.NewDatabase(ctx, name, dEnv.DbData(), opts) } -// newReplicaDatabase creates a new dsqle.ReadReplicaDatabase. In the case of an invalid configuration, returns an +// newReplicaDatabase creates a new dsqle.ReadReplicaDatabase. In the case of an invalid configuration, returns an // error along with a partially constructed database. func newReplicaDatabase(ctx context.Context, name string, remoteName string, dEnv *env.DoltEnv) (sqle.ReadReplicaDatabase, error) { tmpDir, err := dEnv.TempTableFilesDir() From 64d1f42c1ec456df477c8daea14b62ba2a164821 Mon Sep 17 00:00:00 2001 From: Zach Musgrave Date: Thu, 25 May 2023 16:27:45 -0700 Subject: [PATCH 4/8] Remove obsolete error handling tests --- integration-tests/bats/replication.bats | 41 ------------------------- 1 file changed, 41 deletions(-) diff --git a/integration-tests/bats/replication.bats b/integration-tests/bats/replication.bats index 2cafd4ff66..d0c7a5739b 100644 --- a/integration-tests/bats/replication.bats +++ b/integration-tests/bats/replication.bats @@ -395,36 +395,6 @@ SQL [[ "$output" =~ "branch not found" ]] || false } -@test "replication: pull with no head configuration fails" { - dolt clone file://./rem1 repo2 - cd repo2 - dolt branch new_feature - dolt push origin new_feature - - cd ../repo1 - dolt config --local --add sqlserver.global.dolt_read_replica_remote remote1 - run dolt sql -q "show tables" - [ "$status" -eq 1 ] - [[ ! "$output" =~ "panic" ]] || false - [[ "$output" =~ "invalid replicate heads setting: dolt_replicate_heads not set" ]] || false -} - -@test "replication: replica pull conflicting head configurations" { - dolt clone file://./rem1 repo2 - cd repo2 - dolt branch new_feature - dolt push origin new_feature - - cd ../repo1 - dolt config --local --add sqlserver.global.dolt_replicate_heads main,unknown - dolt config --local --add sqlserver.global.dolt_replicate_all_heads 1 - dolt config --local --add sqlserver.global.dolt_read_replica_remote remote1 - run dolt sql -q "show tables" - [ "$status" -eq 1 ] - [[ ! "$output" =~ "panic" ]] || false - [[ "$output" =~ "invalid replicate heads setting; cannot set both" ]] || false -} - @test "replication: replica pull multiple heads quiet warnings" { dolt clone file://./rem1 repo2 cd repo2 @@ -615,17 +585,6 @@ SQL [[ ! "$output" =~ "remote not found: 'unknown'" ]] || false } -@test "replication: pull bad remote errors" { - cd repo1 - dolt config --local --add sqlserver.global.dolt_read_replica_remote unknown - dolt config --local --add sqlserver.global.dolt_replicate_heads main - - run dolt sql -q "show tables" - [ "$status" -eq 1 ] - [[ ! "$output" =~ "panic" ]] - [[ "$output" =~ "remote not found: 'unknown'" ]] || false -} - @test "replication: non-fast-forward pull fails replication" { dolt clone file://./rem1 clone1 cd clone1 From 3820832239bedbbbf432ada818e1f24e41c2dfd2 Mon Sep 17 00:00:00 2001 From: Zach Musgrave Date: Fri, 26 May 2023 10:59:49 -0700 Subject: [PATCH 5/8] consolidated replication hook logic more, made more things warnings instead of errors --- go/cmd/dolt/commands/engine/utils.go | 96 +------------------ go/cmd/dolt/commands/sql_test.go | 14 +-- go/libraries/doltcore/sqle/replication.go | 17 ++-- .../bats/helper/query-server-common.bash | 8 +- .../bats/remotes-sql-server.bats | 33 ++++--- 5 files changed, 39 insertions(+), 129 deletions(-) diff --git a/go/cmd/dolt/commands/engine/utils.go b/go/cmd/dolt/commands/engine/utils.go index 94412e69c4..2b08ab2579 100644 --- a/go/cmd/dolt/commands/engine/utils.go +++ b/go/cmd/dolt/commands/engine/utils.go @@ -16,18 +16,12 @@ package engine import ( "context" - "fmt" - "github.com/dolthub/go-mysql-server/sql" - - "github.com/dolthub/dolt/go/cmd/dolt/cli" - "github.com/dolthub/dolt/go/libraries/doltcore/doltdb" "github.com/dolthub/dolt/go/libraries/doltcore/env" "github.com/dolthub/dolt/go/libraries/doltcore/sqle" "github.com/dolthub/dolt/go/libraries/doltcore/sqle/dsess" "github.com/dolthub/dolt/go/libraries/doltcore/table/editor" "github.com/dolthub/dolt/go/libraries/utils/filesys" - "github.com/dolthub/dolt/go/store/types" ) // CollectDBs takes a MultiRepoEnv and creates Database objects from each environment and returns a slice of these @@ -38,12 +32,6 @@ func CollectDBs(ctx context.Context, mrEnv *env.MultiRepoEnv, useBulkEditor bool var db dsess.SqlDatabase err := mrEnv.Iter(func(name string, dEnv *env.DoltEnv) (stop bool, err error) { - postCommitHooks, err := GetCommitHooks(ctx, dEnv) - if err != nil { - return true, err - } - dEnv.DoltDB.SetCommitHooks(ctx, postCommitHooks) - db, err = newDatabase(ctx, name, dEnv, useBulkEditor) if err != nil { return false, err @@ -62,27 +50,6 @@ func CollectDBs(ctx context.Context, mrEnv *env.MultiRepoEnv, useBulkEditor bool return dbs, locations, nil } -// GetCommitHooks creates a list of hooks to execute on database commit. If doltdb.SkipReplicationErrorsKey is set, -// replace misconfigured hooks with doltdb.LogHook instances that prints a warning when trying to execute. -// TODO: this duplicates code in the sqle package -func GetCommitHooks(ctx context.Context, dEnv *env.DoltEnv) ([]doltdb.CommitHook, error) { - postCommitHooks := make([]doltdb.CommitHook, 0) - - if hook, err := getPushOnWriteHook(ctx, dEnv); err != nil { - path, _ := dEnv.FS.Abs(".") - err = fmt.Errorf("failure loading hook for database at %s; %w", path, err) - if dsess.IgnoreReplicationErrors() { - postCommitHooks = append(postCommitHooks, doltdb.NewLogHook([]byte(err.Error()+"\n"))) - } else { - return nil, err - } - } else if hook != nil { - postCommitHooks = append(postCommitHooks, hook) - } - - return postCommitHooks, nil -} - func newDatabase(ctx context.Context, name string, dEnv *env.DoltEnv, useBulkEditor bool) (sqle.Database, error) { deaf := dEnv.DbEaFactory() if useBulkEditor { @@ -97,65 +64,4 @@ func newDatabase(ctx context.Context, name string, dEnv *env.DoltEnv, useBulkEdi Tempdir: tmpDir, } return sqle.NewDatabase(ctx, name, dEnv.DbData(), opts) -} - -// newReplicaDatabase creates a new dsqle.ReadReplicaDatabase. In the case of an invalid configuration, returns an -// error along with a partially constructed database. -func newReplicaDatabase(ctx context.Context, name string, remoteName string, dEnv *env.DoltEnv) (sqle.ReadReplicaDatabase, error) { - tmpDir, err := dEnv.TempTableFilesDir() - if err != nil { - return sqle.ReadReplicaDatabase{}, err - } - opts := editor.Options{ - Deaf: dEnv.DbEaFactory(), - Tempdir: tmpDir, - } - - db, err := sqle.NewDatabase(ctx, name, dEnv.DbData(), opts) - if err != nil { - return sqle.ReadReplicaDatabase{}, err - } - - rrd, err := sqle.NewReadReplicaDatabase(ctx, db, remoteName, dEnv) - if err != nil { - err = fmt.Errorf("%w from remote '%s'; %s", sqle.ErrFailedToLoadReplicaDB, remoteName, err.Error()) - cli.Println(err) - return sqle.ReadReplicaDatabase{Database: db}, err - } - return rrd, nil -} - -func getPushOnWriteHook(ctx context.Context, dEnv *env.DoltEnv) (*doltdb.PushOnWriteHook, error) { - _, val, ok := sql.SystemVariables.GetGlobal(dsess.ReplicateToRemote) - if !ok { - return nil, sql.ErrUnknownSystemVariable.New(dsess.ReplicateToRemote) - } else if val == "" { - return nil, nil - } - - remoteName, ok := val.(string) - if !ok { - return nil, sql.ErrInvalidSystemVariableValue.New(val) - } - - remotes, err := dEnv.GetRemotes() - if err != nil { - return nil, err - } - - rem, ok := remotes[remoteName] - if !ok { - return nil, fmt.Errorf("%w: '%s'", env.ErrRemoteNotFound, remoteName) - } - - ddb, err := rem.GetRemoteDB(ctx, types.Format_Default, dEnv) - if err != nil { - return nil, err - } - tmpDir, err := dEnv.TempTableFilesDir() - if err != nil { - return nil, err - } - pushHook := doltdb.NewPushOnWriteHook(ddb, tmpDir) - return pushHook, nil -} +} \ No newline at end of file diff --git a/go/cmd/dolt/commands/sql_test.go b/go/cmd/dolt/commands/sql_test.go index 82dfb921ae..75656a317a 100644 --- a/go/cmd/dolt/commands/sql_test.go +++ b/go/cmd/dolt/commands/sql_test.go @@ -17,6 +17,7 @@ package commands import ( "context" "fmt" + "io" "testing" "github.com/dolthub/go-mysql-server/sql" @@ -25,22 +26,12 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/dolthub/dolt/go/cmd/dolt/commands/engine" "github.com/dolthub/dolt/go/libraries/doltcore/doltdb" "github.com/dolthub/dolt/go/libraries/doltcore/dtestutils" "github.com/dolthub/dolt/go/libraries/doltcore/sqle" "github.com/dolthub/dolt/go/libraries/doltcore/sqle/dsess" ) -//var UUIDS = []uuid.UUID{ -// uuid.Must(uuid.Parse("00000000-0000-0000-0000-000000000000")), -// uuid.Must(uuid.Parse("00000000-0000-0000-0000-000000000001")), -// uuid.Must(uuid.Parse("00000000-0000-0000-0000-000000000002"))} -//var Names = []string{"Bill Billerson", "John Johnson", "Rob Robertson"} -//var Ages = []uint64{32, 25, 21} -//var Titles = []string{"Senior Dufus", "Dufus", ""} -//var MaritalStatus = []bool{true, false, false} - var tableName = "people" // Smoke test: Console opens and exits @@ -622,9 +613,8 @@ func TestCommitHooksNoErrors(t *testing.T) { defer dEnv.DoltDB.Close() sqle.AddDoltSystemVariables() - sql.SystemVariables.SetGlobal(dsess.SkipReplicationErrors, true) sql.SystemVariables.SetGlobal(dsess.ReplicateToRemote, "unknown") - hooks, err := engine.GetCommitHooks(context.Background(), dEnv) + hooks, err := sqle.GetCommitHooks(context.Background(), nil, dEnv, io.Discard) assert.NoError(t, err) if len(hooks) < 1 { t.Error("failed to produce noop hook") diff --git a/go/libraries/doltcore/sqle/replication.go b/go/libraries/doltcore/sqle/replication.go index cb2191c76f..5e393e3ec5 100644 --- a/go/libraries/doltcore/sqle/replication.go +++ b/go/libraries/doltcore/sqle/replication.go @@ -69,25 +69,22 @@ func getPushOnWriteHook(ctx context.Context, bThreads *sql.BackgroundThreads, dE return doltdb.NewPushOnWriteHook(ddb, tmpDir), nil } -// GetCommitHooks creates a list of hooks to execute on database commit. If doltdb.SkipReplicationErrorsKey is set, -// replace misconfigured hooks with doltdb.LogHook instances that prints a warning when trying to execute. +// GetCommitHooks creates a list of hooks to execute on database commit. Hooks that cannot be created because of an +// error in configuration will not prevent the server from starting, and will instead log errors. func GetCommitHooks(ctx context.Context, bThreads *sql.BackgroundThreads, dEnv *env.DoltEnv, logger io.Writer) ([]doltdb.CommitHook, error) { postCommitHooks := make([]doltdb.CommitHook, 0) - if hook, err := getPushOnWriteHook(ctx, bThreads, dEnv, logger); err != nil { + hook, err := getPushOnWriteHook(ctx, bThreads, dEnv, logger) + if err != nil { path, _ := dEnv.FS.Abs(".") - err = fmt.Errorf("failure loading hook for database at %s; %w", path, err) - if dsess.IgnoreReplicationErrors() { - postCommitHooks = append(postCommitHooks, doltdb.NewLogHook([]byte(err.Error()+"\n"))) - } else { - return nil, err - } + logrus.Errorf("error loading replication for database at %s, replication disabled: %v", path, err) + postCommitHooks = append(postCommitHooks, doltdb.NewLogHook([]byte(err.Error()+"\n"))) } else if hook != nil { postCommitHooks = append(postCommitHooks, hook) } for _, h := range postCommitHooks { - h.SetLogger(ctx, logger) + _ = h.SetLogger(ctx, logger) } return postCommitHooks, nil } diff --git a/integration-tests/bats/helper/query-server-common.bash b/integration-tests/bats/helper/query-server-common.bash index 338f574032..68bbcae6ea 100644 --- a/integration-tests/bats/helper/query-server-common.bash +++ b/integration-tests/bats/helper/query-server-common.bash @@ -31,8 +31,14 @@ wait_for_connection(port=int(port_str), timeout_ms=int(timeout_ms), database=dat start_sql_server() { DEFAULT_DB="$1" + logFile="$2" PORT=$( definePORT ) - dolt sql-server --host 0.0.0.0 --port=$PORT --user dolt --socket "dolt.$PORT.sock" & + if [[ $logFile ]] + then + dolt sql-server --host 0.0.0.0 --port=$PORT --user dolt --socket "dolt.$PORT.sock" > $logFile 2>&1 & + else + dolt sql-server --host 0.0.0.0 --port=$PORT --user dolt --socket "dolt.$PORT.sock" & + fi SERVER_PID=$! wait_for_connection $PORT 5000 } diff --git a/integration-tests/bats/remotes-sql-server.bats b/integration-tests/bats/remotes-sql-server.bats index 47f6b9c060..f21d08a268 100644 --- a/integration-tests/bats/remotes-sql-server.bats +++ b/integration-tests/bats/remotes-sql-server.bats @@ -120,17 +120,21 @@ teardown() { [[ "$output" =~ "test" ]] || false } -@test "remotes-sql-server: pull remote not found error" { +@test "remotes-sql-server: pull remote not found" { skiponwindows "Missing dependencies" cd repo1 dolt config --local --add sqlserver.global.dolt_read_replica_remote unknown dolt config --local --add sqlserver.global.dolt_replicate_heads main - run dolt sql-server -P 3333 - [ "$status" -eq 1 ] - [[ ! "$output" =~ "panic" ]] - [[ "$output" =~ "remote not found: 'unknown'" ]] || false + start_sql_server repo1 ./server-log.txt + + run dolt sql-client --use-db repo1 -P $PORT -u dolt -q "show tables" + [ $status -eq 0 ] + [[ "$output" =~ "Table" ]] || false + + run grep 'replication disabled' ./server-log.txt + [[ "$output" =~ "replication disabled" ]] || false } @test "remotes-sql-server: quiet pull warnings" { @@ -140,23 +144,30 @@ teardown() { dolt config --local --add sqlserver.global.dolt_skip_replication_errors 1 dolt config --local --add sqlserver.global.dolt_read_replica_remote unknown dolt config --local --add sqlserver.global.dolt_replicate_heads main - start_sql_server repo1 + + start_sql_server repo1 ./server-log.txt run dolt sql-client --use-db repo1 -P $PORT -u dolt -q "show tables" [ $status -eq 0 ] [[ "$output" =~ "Table" ]] || false + + run grep 'failed to load replica database from remote' ./server-log.txt + [[ "$output" =~ "failed to load replica database from remote" ]] || false } -@test "remotes-sql-server: push remote not found error" { +@test "remotes-sql-server: push remote not found" { skiponwindows "Missing dependencies" cd repo1 dolt config --local --add sqlserver.global.dolt_replicate_to_remote unknown - run dolt sql-server -P 3333 - [ "$status" -eq 1 ] - [[ ! "$output" =~ "panic" ]] - [[ "$output" =~ "remote not found: 'unknown'" ]] || false + start_sql_server repo1 ./server-log.txt + + run dolt sql-client --use-db repo1 -P $PORT -u dolt -q "show tables" + [[ "$output" =~ "Table" ]] || false + + run grep 'replication disabled' ./server-log.txt + [[ "$output" =~ "replication disabled" ]] || false } @test "remotes-sql-server: quiet push warnings" { From c509181d05dd1b48d73f0c39e9130d1154ae5fd9 Mon Sep 17 00:00:00 2001 From: Zach Musgrave Date: Fri, 26 May 2023 11:14:02 -0700 Subject: [PATCH 6/8] More test fixes --- integration-tests/bats/replication.bats | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/integration-tests/bats/replication.bats b/integration-tests/bats/replication.bats index d0c7a5739b..ac028c0d6d 100644 --- a/integration-tests/bats/replication.bats +++ b/integration-tests/bats/replication.bats @@ -555,9 +555,10 @@ SQL dolt config --local --add sqlserver.global.dolt_replicate_to_remote unknown run dolt sql -q "create table t1 (a int primary key)" - [ "$status" -eq 1 ] + [ "$status" -eq 0 ] [[ ! "$output" =~ "panic" ]] || false [[ "$output" =~ "remote not found: 'unknown'" ]] || false + [[ "$output" =~ "replication disabled" ]] || false } @test "replication: quiet push to unknown remote warnings" { @@ -566,7 +567,6 @@ SQL dolt config --local --add sqlserver.global.dolt_replicate_to_remote unknown run dolt sql -q "create table t1 (a int primary key)" [ "$status" -eq 0 ] - [[ ! "$output" =~ "remote not found" ]] || false dolt add . From 42c45380cf439c246844640a20dbdcc6288e8563 Mon Sep 17 00:00:00 2001 From: Zach Musgrave Date: Fri, 26 May 2023 11:25:57 -0700 Subject: [PATCH 7/8] Fixed more tests --- integration-tests/bats/replication-multidb.bats | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/integration-tests/bats/replication-multidb.bats b/integration-tests/bats/replication-multidb.bats index 888c8a7dec..7bc31d356a 100644 --- a/integration-tests/bats/replication-multidb.bats +++ b/integration-tests/bats/replication-multidb.bats @@ -274,15 +274,18 @@ SQL @test "replication-multidb: missing database config" { dolt config --global --add sqlserver.global.dolt_replicate_to_remote unknown run dolt --data-dir=dbs1 sql -b -q "use repo1; create table t1 (a int primary key)" - [ "$status" -eq 1 ] - [[ ! "$output" =~ "panic" ]] || false + [ "$status" -eq 0 ] [[ "$output" =~ "remote not found: 'unknown'" ]] || false + [[ "$output" =~ "replication disabled" ]] || false } @test "replication-multidb: missing database config quiet warning" { dolt config --global --add sqlserver.global.dolt_replicate_to_remote unknown dolt config --global --add sqlserver.global.dolt_skip_replication_errors 1 - dolt --data-dir=dbs1 sql -b -q "use repo1; create table t1 (a int primary key)" + run dolt --data-dir=dbs1 sql -b -q "use repo1; create table t1 (a int primary key)" + [ "$status" -eq 0 ] + [[ "$output" =~ "remote not found: 'unknown'" ]] || false + [[ "$output" =~ "replication disabled" ]] || false } @test "replication-multidb: sql-server push on commit" { From f5faad42e08a70005263633a6593a5899e8559c5 Mon Sep 17 00:00:00 2001 From: zachmu Date: Fri, 26 May 2023 19:09:41 +0000 Subject: [PATCH 8/8] [ga-format-pr] Run go/utils/repofmt/format_repo.sh and go/Godeps/update.sh --- go/cmd/dolt/commands/engine/utils.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go/cmd/dolt/commands/engine/utils.go b/go/cmd/dolt/commands/engine/utils.go index 2b08ab2579..4128d3b03b 100644 --- a/go/cmd/dolt/commands/engine/utils.go +++ b/go/cmd/dolt/commands/engine/utils.go @@ -64,4 +64,4 @@ func newDatabase(ctx context.Context, name string, dEnv *env.DoltEnv, useBulkEdi Tempdir: tmpDir, } return sqle.NewDatabase(ctx, name, dEnv.DbData(), opts) -} \ No newline at end of file +}