Skip to content

Commit a3d37f5

Browse files
feat(main): use NetworkTopologyStrategy for SM ks by default
SimpleStrategy is not recommended for the production environments. It also does not support tablets, which are the way towards scylla is moving (in some distant time, vnodes might even be deprecated). Because of that, it also runs into unexpected problems like #4555. Because of those reasons, we should switch from keeping SM data in SimpleStrategy to NetworkTopologyStrategy keyspace by default. For the default, single local node SM DB cluster, both strategies result in the single node containing all of SM data. For single DC SM DB cluster they are also equivalent. On the other hand, for multi DC SM DB cluster (really not recommended...), NetworkTopologyStrategy results in keeping replication_factor replicas per DC and not per cluster. This is theoretically problematic, but such setup is also problematic for SimpleStrategy, which would still replicate the data in all DCs, so it's not a new problem. Moreover, this change only defines the default SM keyspace creation. In case user has some non-default (perhaps not recommended) SM DB setup, they can always create SM keyspace manually before starting SM server to configure it to their liking. Refs #4555
1 parent 6b59292 commit a3d37f5

File tree

1 file changed

+9
-4
lines changed
  • pkg/cmd/scylla-manager

1 file changed

+9
-4
lines changed

pkg/cmd/scylla-manager/db.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ import (
88
"text/template"
99
"time"
1010

11-
"github.com/scylladb/go-log/gocqllog"
12-
1311
"github.com/gocql/gocql"
12+
"github.com/pkg/errors"
1413
"github.com/scylladb/go-log"
14+
"github.com/scylladb/go-log/gocqllog"
1515
"github.com/scylladb/gocqlx/v2"
1616
"github.com/scylladb/gocqlx/v2/dbutil"
1717
"github.com/scylladb/gocqlx/v2/migrate"
@@ -55,10 +55,15 @@ func createKeyspace(ctx context.Context, c config.Config, logger log.Logger) err
5555
}
5656
}
5757

58-
return session.Query(mustEvaluateCreateKeyspaceStmt(c)).Exec()
58+
ksCreateStmt := mustEvaluateCreateKeyspaceStmt(c)
59+
if err := session.Query(ksCreateStmt).Exec(); err != nil {
60+
return errors.Wrapf(err, "failed to create manager keyspace with %q, "+
61+
"consider creating it manually and starting manager server again", ksCreateStmt)
62+
}
63+
return nil
5964
}
6065

61-
const createKeyspaceStmt = "CREATE KEYSPACE {{.Keyspace}} WITH replication = {'class': 'SimpleStrategy', 'replication_factor': {{.ReplicationFactor}}}"
66+
const createKeyspaceStmt = "CREATE KEYSPACE {{.Keyspace}} WITH replication = {'class': 'NetworkTopologyStrategy', 'replication_factor': {{.ReplicationFactor}}}"
6267

6368
func mustEvaluateCreateKeyspaceStmt(c config.Config) string {
6469
t := template.New("")

0 commit comments

Comments
 (0)