From 91b953277c040a8af7e214d478bd71f3a7458682 Mon Sep 17 00:00:00 2001 From: Zach Musgrave Date: Fri, 19 Jan 2024 17:06:47 -0800 Subject: [PATCH 1/3] Simplified warn on error behavior for replication --- go/libraries/doltcore/env/actions/tag.go | 4 --- .../doltcore/sqle/read_replica_database.go | 31 ++++--------------- .../sqle/read_replica_database_test.go | 2 +- go/libraries/doltcore/sqle/replication.go | 10 ++---- 4 files changed, 10 insertions(+), 37 deletions(-) diff --git a/go/libraries/doltcore/env/actions/tag.go b/go/libraries/doltcore/env/actions/tag.go index 52a8eb95d89..ee433e41fc3 100644 --- a/go/libraries/doltcore/env/actions/tag.go +++ b/go/libraries/doltcore/env/actions/tag.go @@ -73,10 +73,6 @@ func CreateTagOnDB(ctx context.Context, ddb *doltdb.DoltDB, tagName, startPoint return ddb.NewTagAtCommit(ctx, tagRef, cm, meta) } -func DeleteTags(ctx context.Context, dEnv *env.DoltEnv, tagNames ...string) error { - return DeleteTagsOnDB(ctx, dEnv.DoltDB, tagNames...) -} - func DeleteTagsOnDB(ctx context.Context, ddb *doltdb.DoltDB, tagNames ...string) error { for _, tn := range tagNames { dref := ref.NewTagRef(tn) diff --git a/go/libraries/doltcore/sqle/read_replica_database.go b/go/libraries/doltcore/sqle/read_replica_database.go index 065d3c9a846..bc59d05f1dc 100644 --- a/go/libraries/doltcore/sqle/read_replica_database.go +++ b/go/libraries/doltcore/sqle/read_replica_database.go @@ -127,19 +127,13 @@ func (rrd ReadReplicaDatabase) PullFromRemote(ctx *sql.Context) error { } err := rrd.srcDB.Rebase(ctx) - if err != nil && !dsess.IgnoreReplicationErrors() { + if err != nil { return err - } else if err != nil { - dsess.WarnReplicationError(ctx, err) - return nil } remoteRefs, localRefs, toDelete, err := getReplicationRefs(ctx, rrd) - if err != nil && !dsess.IgnoreReplicationErrors() { + if err != nil { return err - } else if err != nil { - dsess.WarnReplicationError(ctx, err) - return nil } switch { @@ -194,39 +188,26 @@ func (rrd ReadReplicaDatabase) PullFromRemote(ctx *sql.Context) error { } err := fmt.Errorf("unable to find %q on %q; branch not found", branch, rrd.remote.Name) - if err != nil && !dsess.IgnoreReplicationErrors() { + if err != nil { return err - } else if err != nil { - dsess.WarnReplicationError(ctx, err) - return nil } } remoteRefs = prunedRefs _, err = pullBranches(ctx, rrd, remoteRefs, localRefs, behavior) - - if err != nil && !dsess.IgnoreReplicationErrors() { + if err != nil { return err - } else if err != nil { - dsess.WarnReplicationError(ctx, err) - return nil } case allHeads == int8(1): _, err = pullBranches(ctx, rrd, remoteRefs, localRefs, behavior) - if err != nil && !dsess.IgnoreReplicationErrors() { + if err != nil { return err - } else if err != nil { - dsess.WarnReplicationError(ctx, err) - return nil } err = deleteBranches(ctx, rrd, toDelete) - if err != nil && !dsess.IgnoreReplicationErrors() { + if err != nil { return err - } else if err != nil { - dsess.WarnReplicationError(ctx, err) - return nil } default: ctx.GetLogger().Warnf("must set either @@dolt_replicate_heads or @@dolt_replicate_all_heads, replication disabled") diff --git a/go/libraries/doltcore/sqle/read_replica_database_test.go b/go/libraries/doltcore/sqle/read_replica_database_test.go index aa8b739cfc3..6a501dcbd44 100644 --- a/go/libraries/doltcore/sqle/read_replica_database_test.go +++ b/go/libraries/doltcore/sqle/read_replica_database_test.go @@ -62,7 +62,7 @@ func TestLimiter(t *testing.T) { }() } - // TODO: This is some janky to reduce flakiness. + // TODO: This is some jank to reduce flakiness. sema.Acquire(context.Background(), 16) time.Sleep(10 * time.Millisecond) for i := 0; i < 128; i++ { diff --git a/go/libraries/doltcore/sqle/replication.go b/go/libraries/doltcore/sqle/replication.go index 290e4c902be..6755609194a 100644 --- a/go/libraries/doltcore/sqle/replication.go +++ b/go/libraries/doltcore/sqle/replication.go @@ -22,7 +22,6 @@ import ( "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" "github.com/dolthub/dolt/go/libraries/doltcore/env" "github.com/dolthub/dolt/go/libraries/doltcore/sqle/dsess" @@ -104,13 +103,10 @@ func newReplicaDatabase(ctx context.Context, name string, remoteName string, dEn rrd, err := NewReadReplicaDatabase(ctx, db, remoteName, dEnv) if err != nil { - err = fmt.Errorf("%w from remote '%s'; %s", ErrFailedToLoadReplicaDB, remoteName, err.Error()) - if !dsess.IgnoreReplicationErrors() { - return ReadReplicaDatabase{}, err - } - cli.Println(err) - return ReadReplicaDatabase{Database: db}, nil + err = fmt.Errorf("%s from remote '%s'; %w", ErrFailedToLoadReplicaDB.Error(), remoteName, err) + return ReadReplicaDatabase{}, err } + return rrd, nil } From 0d27120afd29ece4f9f1eac84a2c149a98bae7cc Mon Sep 17 00:00:00 2001 From: Zach Musgrave Date: Fri, 19 Jan 2024 17:29:42 -0800 Subject: [PATCH 2/3] Added test for deleting tags --- integration-tests/bats/replication.bats | 29 +++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/integration-tests/bats/replication.bats b/integration-tests/bats/replication.bats index 4ac1623f2dd..e6d80c8e94b 100644 --- a/integration-tests/bats/replication.bats +++ b/integration-tests/bats/replication.bats @@ -108,6 +108,35 @@ teardown() { [[ ! "$output" =~ "feature" ]] || false } +@test "replication: push tag delete, pull delete on read" { + cd repo1 + dolt tag tag1 + dolt tag tag2 + dolt push remote1 tag1 + dolt push remote1 tag2 + + cd .. + dolt clone file://./rem1 repo2 + cd repo2 + dolt config --local --add sqlserver.global.dolt_read_replica_remote origin + dolt config --local --add sqlserver.global.dolt_replicate_all_heads 1 + + run dolt sql -q "select tag_name from dolt_tags" -r csv + [ "$status" -eq 0 ] + [[ "$output" =~ "tag1" ]] || false + [[ "$output" =~ "tag2" ]] || false + + cd ../repo1 + dolt config --local --add sqlserver.global.dolt_replicate_to_remote remote1 + dolt tag -d tag1 + + cd ../repo2 + run dolt sql -q "select tag_name from dolt_tags" -r csv + [ "$status" -eq 0 ] + [[ ! "$output" =~ "tag1" ]] || false + [[ "$output" =~ "tag2" ]] || false +} + @test "replication: pull branch delete on read" { cd repo1 dolt push remote1 feature From da1bb8df16efa89d87c23727866c76c2bd049e48 Mon Sep 17 00:00:00 2001 From: zachmu Date: Sat, 20 Jan 2024 01:42:11 +0000 Subject: [PATCH 3/3] [ga-format-pr] Run go/utils/repofmt/format_repo.sh and go/Godeps/update.sh --- go/libraries/doltcore/sqle/replication.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go/libraries/doltcore/sqle/replication.go b/go/libraries/doltcore/sqle/replication.go index 6755609194a..602966373d7 100644 --- a/go/libraries/doltcore/sqle/replication.go +++ b/go/libraries/doltcore/sqle/replication.go @@ -106,7 +106,7 @@ func newReplicaDatabase(ctx context.Context, name string, remoteName string, dEn err = fmt.Errorf("%s from remote '%s'; %w", ErrFailedToLoadReplicaDB.Error(), remoteName, err) return ReadReplicaDatabase{}, err } - + return rrd, nil }