Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add bvt #12344

Merged
merged 7 commits into from
Oct 27, 2023
Merged

add bvt #12344

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 20 additions & 6 deletions cmd/mo-service/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down Expand Up @@ -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 {
Expand Down
6 changes: 4 additions & 2 deletions pkg/cnservice/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand Down Expand Up @@ -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.
Expand Down
2 changes: 2 additions & 0 deletions pkg/cnservice/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion pkg/frontend/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
10 changes: 7 additions & 3 deletions pkg/logutil/internal.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions pkg/util/dump_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"github.com/matrixorigin/matrixone/pkg/common/moerr"
logservicepb "github.com/matrixorigin/matrixone/pkg/pb/logservice"
"reflect"
"strings"
"sync/atomic"
)

Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
22 changes: 22 additions & 0 deletions test/distributed/cases/pessimistic_transaction/system_view.sql
Original file line number Diff line number Diff line change
@@ -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;
35 changes: 35 additions & 0 deletions test/distributed/cases/view/system_view.result
Original file line number Diff line number Diff line change
@@ -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
31 changes: 31 additions & 0 deletions test/distributed/cases/view/system_view.sql
Original file line number Diff line number Diff line change
@@ -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';