@@ -35,6 +35,7 @@ import (
35
35
logbackupconf "github.com/pingcap/tidb/br/pkg/streamhelper/config"
36
36
"github.com/pingcap/tidb/parser/terror"
37
37
"github.com/pingcap/tidb/util/logutil"
38
+ "github.com/pingcap/tidb/util/tiflashcompute"
38
39
"github.com/pingcap/tidb/util/tikvutil"
39
40
"github.com/pingcap/tidb/util/versioninfo"
40
41
tikvcfg "github.com/tikv/client-go/v2/config"
@@ -287,7 +288,14 @@ type Config struct {
287
288
Plugin Plugin `toml:"plugin" json:"plugin"`
288
289
MaxServerConnections uint32 `toml:"max-server-connections" json:"max-server-connections"`
289
290
RunDDL bool `toml:"run-ddl" json:"run-ddl"`
290
- DisaggregatedTiFlash bool `toml:"disaggregated-tiflash" json:"disaggregated-tiflash"`
291
+
292
+ // These configs are related to disaggregated-tiflash mode.
293
+ DisaggregatedTiFlash bool `toml:"disaggregated-tiflash" json:"disaggregated-tiflash"`
294
+ TiFlashComputeAutoScalerType string `toml:"autoscaler-type" json:"autoscaler-type"`
295
+ TiFlashComputeAutoScalerAddr string `toml:"autoscaler-addr" json:"autoscaler-addr"`
296
+ IsTiFlashComputeFixedPool bool `toml:"is-tiflashcompute-fixed-pool" json:"is-tiflashcompute-fixed-pool"`
297
+ AutoScalerClusterID string `toml:"autoscaler-cluster-id" json:"autoscaler-cluster-id"`
298
+
291
299
// TiDBMaxReuseChunk indicates max cached chunk num
292
300
TiDBMaxReuseChunk uint32 `toml:"tidb-max-reuse-chunk" json:"tidb-max-reuse-chunk"`
293
301
// TiDBMaxReuseColumn indicates max cached column num
@@ -1000,6 +1008,10 @@ var defaultConf = Config{
1000
1008
EnableGlobalKill : true ,
1001
1009
TrxSummary : DefaultTrxSummary (),
1002
1010
DisaggregatedTiFlash : false ,
1011
+ TiFlashComputeAutoScalerType : tiflashcompute .DefASStr ,
1012
+ TiFlashComputeAutoScalerAddr : tiflashcompute .DefAWSAutoScalerAddr ,
1013
+ IsTiFlashComputeFixedPool : false ,
1014
+ AutoScalerClusterID : "" ,
1003
1015
TiDBMaxReuseChunk : 64 ,
1004
1016
TiDBMaxReuseColumn : 256 ,
1005
1017
TiDBEnableExitCheck : false ,
@@ -1031,6 +1043,26 @@ func StoreGlobalConfig(config *Config) {
1031
1043
tikvcfg .StoreGlobalConfig (& cfg )
1032
1044
}
1033
1045
1046
+ // GetAutoScalerClusterID returns KeyspaceName or AutoScalerClusterID.
1047
+ func GetAutoScalerClusterID () (string , error ) {
1048
+ c := GetGlobalConfig ()
1049
+ keyspaceName := c .KeyspaceName
1050
+ clusterID := c .AutoScalerClusterID
1051
+
1052
+ if keyspaceName != "" && clusterID != "" {
1053
+ return "" , errors .Errorf ("config.KeyspaceName(%s) and config.AutoScalerClusterID(%s) are not empty both" , keyspaceName , clusterID )
1054
+ }
1055
+ if keyspaceName == "" && clusterID == "" {
1056
+ return "" , errors .Errorf ("config.KeyspaceName and config.AutoScalerClusterID are both empty" )
1057
+ }
1058
+
1059
+ res := keyspaceName
1060
+ if res == "" {
1061
+ res = clusterID
1062
+ }
1063
+ return res , nil
1064
+ }
1065
+
1034
1066
// removedConfig contains items that are no longer supported.
1035
1067
// they might still be in the config struct to support import,
1036
1068
// but are not actively used.
@@ -1315,6 +1347,17 @@ func (c *Config) Valid() error {
1315
1347
return fmt .Errorf ("stats-load-queue-size should be [%d, %d]" , DefStatsLoadQueueSizeLimit , DefMaxOfStatsLoadQueueSizeLimit )
1316
1348
}
1317
1349
1350
+ // Check tiflash_compute topo fetch is valid.
1351
+ if c .DisaggregatedTiFlash {
1352
+ if ! tiflashcompute .IsValidAutoScalerConfig (c .TiFlashComputeAutoScalerType ) {
1353
+ return fmt .Errorf ("invalid AutoScaler type, expect %s, %s or %s, got %s" ,
1354
+ tiflashcompute .MockASStr , tiflashcompute .AWSASStr , tiflashcompute .GCPASStr , c .TiFlashComputeAutoScalerType )
1355
+ }
1356
+ if c .TiFlashComputeAutoScalerAddr == "" {
1357
+ return fmt .Errorf ("autoscaler-addr cannot be empty when disaggregated-tiflash mode is true" )
1358
+ }
1359
+ }
1360
+
1318
1361
// test log level
1319
1362
l := zap .NewAtomicLevel ()
1320
1363
return l .UnmarshalText ([]byte (c .Log .Level ))
0 commit comments