diff --git a/cmd/mo-service/config.go b/cmd/mo-service/config.go index 93d61bb99159d..40be588991e78 100644 --- a/cmd/mo-service/config.go +++ b/cmd/mo-service/config.go @@ -261,6 +261,20 @@ func (c *Config) setDefaultValue() error { if c.Log.StacktraceLevel == "" { c.Log.StacktraceLevel = zap.PanicLevel.String() } + //set set default value + c.Log = logutil.GetDefaultConfig() + // HAKeeperClient has been set in NewConfig + if c.TN_please_use_getTNServiceConfig != nil { + c.TN_please_use_getTNServiceConfig.SetDefaultValue() + } + if c.TNCompatible != nil { + c.TNCompatible.SetDefaultValue() + } + // LogService has been set in NewConfig + c.CN.SetDefaultValue() + //no default proxy config + // Observability has been set in NewConfig + c.initMetaCache() return nil } @@ -576,15 +590,15 @@ func dumpCommonConfig(cfg Config) (map[string]*logservicepb.ConfigItem, error) { //specific config items should be remoted filters := []string{ - "Config.TN_please_use_getTNServiceConfig", - "Config.TNCompatible", - "Config.LogService", - "Config.CN", - "Config.ProxyConfig", + "config.tn_please_use_gettnserviceconfig", + "config.tncompatible", + "config.logservice", + "config.cn", + "config.proxyconfig", } //denote the common for cn,tn,log or proxy - prefix := "Common" + prefix := "common" newMap := make(map[string]*logservicepb.ConfigItem) for s, item := range ret { diff --git a/pkg/cnservice/server.go b/pkg/cnservice/server.go index 94bfb231d4483..174a2f53da020 100644 --- a/pkg/cnservice/server.go +++ b/pkg/cnservice/server.go @@ -69,6 +69,10 @@ func NewService( return nil, err } + //set frontend parameters + cfg.Frontend.SetDefaultValues() + cfg.Frontend.SetMaxMessageSize(uint64(cfg.RPC.MaxMessageSize)) + configKVMap, _ := dumpCnConfig(*cfg) options = append(options, WithConfigData(configKVMap)) @@ -130,8 +134,6 @@ func NewService( Addr: srv.pipelineServiceServiceAddr(), }}) pu.HAKeeperClient = srv._hakeeperClient - cfg.Frontend.SetDefaultValues() - cfg.Frontend.SetMaxMessageSize(uint64(cfg.RPC.MaxMessageSize)) frontend.InitServerVersion(pu.SV.MoVersion) // Init the autoIncrCacheManager after the default value is set before the init of moserver. diff --git a/pkg/cnservice/types.go b/pkg/cnservice/types.go index 6b91ff2d094b7..6c6e04d22e69c 100644 --- a/pkg/cnservice/types.go +++ b/pkg/cnservice/types.go @@ -515,6 +515,8 @@ func (c *Config) SetDefaultValue() { if !metadata.ValidStateString(c.InitWorkState) { c.InitWorkState = metadata.WorkState_Working.String() } + + c.Frontend.SetDefaultValues() } func (s *service) getLockServiceConfig() lockservice.Config { diff --git a/pkg/frontend/session.go b/pkg/frontend/session.go index 23199ddf1d99a..c795317d84326 100644 --- a/pkg/frontend/session.go +++ b/pkg/frontend/session.go @@ -2229,7 +2229,7 @@ func uuid2Str(uid uuid.UUID) string { if bytes.Equal(uid[:], dumpUUID[:]) { return "" } - return uid.String() + return strings.ReplaceAll(uid.String(), "-", "") } func (ses *Session) SetSessionRoutineStatus(status string) error { diff --git a/pkg/logutil/internal.go b/pkg/logutil/internal.go index 6a5faa5bebd9b..e5123ded81562 100644 --- a/pkg/logutil/internal.go +++ b/pkg/logutil/internal.go @@ -50,12 +50,16 @@ var _errorLogger atomic.Value // init initializes a default zap logger before set up logger. func init() { SetLogReporter(&TraceReporter{noopReportZap, noopContextField}) - conf := &LogConfig{Level: "info", Format: "console", StacktraceLevel: "panic"} - setGlobalLogConfig(conf) - logger, _ := initMOLogger(conf) + conf := GetDefaultConfig() + setGlobalLogConfig(&conf) + logger, _ := initMOLogger(&conf) replaceGlobalLogger(logger) } +func GetDefaultConfig() LogConfig { + return LogConfig{Level: "info", Format: "console", StacktraceLevel: "panic"} +} + // GetGlobalLogger returns the current global zap Logger. func GetGlobalLogger() *zap.Logger { return _globalLogger.Load().(*zap.Logger) diff --git a/pkg/util/dump_config.go b/pkg/util/dump_config.go index 159af39c86200..92acc559c201c 100644 --- a/pkg/util/dump_config.go +++ b/pkg/util/dump_config.go @@ -19,6 +19,7 @@ import ( "github.com/matrixorigin/matrixone/pkg/common/moerr" logservicepb "github.com/matrixorigin/matrixone/pkg/pb/logservice" "reflect" + "strings" "sync/atomic" ) @@ -50,6 +51,7 @@ func newExporter() *exporter { } func (et *exporter) Export(k, v, userSet string) { + k = strings.ToLower(k) et.kvs[k] = item{ v: v, userSet: userSet, diff --git a/test/distributed/cases/pessimistic_transaction/system_view.result b/test/distributed/cases/pessimistic_transaction/system_view.result new file mode 100644 index 0000000000000..d4a006a56d45d --- /dev/null +++ b/test/distributed/cases/pessimistic_transaction/system_view.result @@ -0,0 +1,18 @@ +drop database if exists sv_db1; +create database sv_db1; +use sv_db1; +use sv_db1; +create table t1(a int); +begin; +insert into t1 values (1); +select sleep(10); +sleep(10) +0 +select count(*) > 0 from mo_locks() l; +count(*) > 0 +true +select count(*) > 0 from mo_transactions() t join mo_locks() l where t.txn_id = l.txn_id; +count(*) > 0 +true +commit; +drop database if exists sv_db1; diff --git a/test/distributed/cases/pessimistic_transaction/system_view.sql b/test/distributed/cases/pessimistic_transaction/system_view.sql new file mode 100644 index 0000000000000..047e9fffbe2bf --- /dev/null +++ b/test/distributed/cases/pessimistic_transaction/system_view.sql @@ -0,0 +1,22 @@ +--test mo_locks, mo_transactions + +drop database if exists sv_db1; +create database sv_db1; +use sv_db1; + +-- @session:id=1{ +use sv_db1; +create table t1(a int); +begin; +insert into t1 values (1); +select sleep(10); +-- @session} + +select count(*) > 0 from mo_locks() l; +select count(*) > 0 from mo_transactions() t join mo_locks() l where t.txn_id = l.txn_id; + +-- @session:id=1{ +commit; +-- @session} + +drop database if exists sv_db1; \ No newline at end of file diff --git a/test/distributed/cases/view/system_view.result b/test/distributed/cases/view/system_view.result new file mode 100644 index 0000000000000..76bd24039cb10 --- /dev/null +++ b/test/distributed/cases/view/system_view.result @@ -0,0 +1,35 @@ +begin; +select sleep(10); +sleep(10) +0 +select count(*) > 0 from mo_sessions() t; +count(*) > 0 +true +select count(*) > 0 from mo_sessions() as t where txn_id != ''; +count(*) > 0 +true +select count(*) > 0 from mo_transactions() t join mo_sessions() s on t.txn_id = s.txn_id; +count(*) > 0 +true +commit; +select count(*) > 0 from mo_cache() c; +count(*) > 0 +true +select count(*) >0 from mo_configurations() t; +count(*) > 0 +true +select count(*) >0 from mo_configurations() t where node_type = 'cn'; +count(*) > 0 +true +select distinct node_type,default_value from mo_configurations() t where name like '%frontend.port'; +node_type default_value +cn 6001 +select count(*) > 0 from mo_configurations() t where internal = 'advanced'; +count(*) > 0 +true +select count(*) > 0 from mo_catalog.mo_variables; +count(*) > 0 +true +select variable_value from mo_catalog.mo_variables where variable_name = 'port' and account_name = 'sys'; +variable_value +6001 diff --git a/test/distributed/cases/view/system_view.sql b/test/distributed/cases/view/system_view.sql new file mode 100644 index 0000000000000..6693c7e756fe6 --- /dev/null +++ b/test/distributed/cases/view/system_view.sql @@ -0,0 +1,31 @@ +--test mo_sessions + +-- @session:id=1{ +begin; +select sleep(10); +-- @session} + +select count(*) > 0 from mo_sessions() t; +select count(*) > 0 from mo_sessions() as t where txn_id != ''; +select count(*) > 0 from mo_transactions() t join mo_sessions() s on t.txn_id = s.txn_id; + +-- @session:id=1{ +commit; +-- @session} + + +-- test mo_cache + +select count(*) > 0 from mo_cache() c; + +-- test mo_configurations + +select count(*) >0 from mo_configurations() t; +select count(*) >0 from mo_configurations() t where node_type = 'cn'; + +select distinct node_type,default_value from mo_configurations() t where name like '%frontend.port'; +select count(*) > 0 from mo_configurations() t where internal = 'advanced'; + +-- test mo_variables +select count(*) > 0 from mo_catalog.mo_variables; +select variable_value from mo_catalog.mo_variables where variable_name = 'port' and account_name = 'sys'; \ No newline at end of file