Skip to content

Commit 850f18c

Browse files
authored
added more configurations to cal event (#400)
1 parent 4af3606 commit 850f18c

File tree

1 file changed

+83
-18
lines changed

1 file changed

+83
-18
lines changed

lib/config.go

+83-18
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,12 @@ import (
2929
"sync/atomic"
3030
)
3131

32-
//The Config contains all the static configuration
32+
const (
33+
mux_config_cal_name = "OCC_CONFIG"
34+
oracle_worker_config_cal_name = "OCC_ORACLE_WORKER_CONFIG"
35+
)
36+
37+
// The Config contains all the static configuration
3338
type Config struct {
3439
CertChainFile string
3540
KeyFile string // leave blank for no SSL
@@ -179,6 +184,14 @@ type Config struct {
179184

180185
// Max desired percentage of healthy workers for the worker pool
181186
MaxDesiredHealthyWorkerPct int
187+
188+
// Oracle Worker Configs
189+
EnableCache bool
190+
EnableHeartBeat bool
191+
EnableQueryReplaceNL bool
192+
EnableBindHashLogging bool
193+
EnableSessionVariables bool
194+
UseNonBlocking bool
182195
}
183196

184197
// The OpsConfig contains the configuration that can be modified during run time
@@ -230,7 +243,6 @@ func InitConfig() error {
230243
} else {
231244
currentDir = currentDir + "/"
232245
}
233-
234246
filename := currentDir + "hera.txt"
235247

236248
cdb, err := config.NewTxtConfig(filename)
@@ -308,6 +320,7 @@ func InitConfig() error {
308320
}
309321

310322
gAppConfig.EnableSharding = cdb.GetOrDefaultBool("enable_sharding", false)
323+
311324
gAppConfig.UseShardMap = cdb.GetOrDefaultBool("use_shardmap", true)
312325
gAppConfig.NumOfShards = cdb.GetOrDefaultInt("num_shards", 1)
313326
if gAppConfig.EnableSharding == false || gAppConfig.UseShardMap == false {
@@ -366,6 +379,14 @@ func InitConfig() error {
366379
// TODO:
367380
gAppConfig.NumStdbyDbs = 1
368381

382+
// Fetch Oracle worker configurations.. The defaults must be same between oracle worker and here for accurate logging.
383+
gAppConfig.EnableCache = cdb.GetOrDefaultBool("enable_cache", false)
384+
gAppConfig.EnableHeartBeat = cdb.GetOrDefaultBool("enable_heart_beat", false)
385+
gAppConfig.EnableQueryReplaceNL = cdb.GetOrDefaultBool("enable_query_replace_nl", true)
386+
gAppConfig.EnableBindHashLogging = cdb.GetOrDefaultBool("enable_bind_hash_logging", false)
387+
gAppConfig.EnableSessionVariables = cdb.GetOrDefaultBool("enable_session_variables", false)
388+
gAppConfig.UseNonBlocking = cdb.GetOrDefaultBool("use_non_blocking", false)
389+
369390
var numWorkers int
370391
numWorkers = 6
371392
//err = config.InitOpsConfigWithName("../opscfg/hera.txt")
@@ -500,17 +521,15 @@ func LogOccConfigs() {
500521
"hostname_prefix": gAppConfig.HostnamePrefix,
501522
"sharding_cross_keys_err": gAppConfig.ShardingCrossKeysErr,
502523
//"enable_sql_rewrite", // not found anywhere?
503-
"sharding_algo": gAppConfig.ShardingAlgoHash,
504-
"cfg_from_tns_override_num_shards": gAppConfig.CfgFromTnsOverrideNumShards,
524+
"sharding_algo": gAppConfig.ShardingAlgoHash,
505525
},
506526
"TAF": {
507-
"enable_taf": gAppConfig.EnableTAF,
508-
"cfg_from_tns_override_taf": gAppConfig.CfgFromTnsOverrideTaf,
509-
"testing_enable_dml_taf": gAppConfig.TestingEnableDMLTaf,
510-
"taf_timeout_ms": gAppConfig.TAFTimeoutMs,
511-
"taf_bin_duration": gAppConfig.TAFBinDuration,
512-
"taf_allow_slow_every_x": gAppConfig.TAFAllowSlowEveryX,
513-
"taf_normally_slow_count": gAppConfig.TAFNormallySlowCount,
527+
"enable_taf": gAppConfig.EnableTAF,
528+
"testing_enable_dml_taf": gAppConfig.TestingEnableDMLTaf,
529+
"taf_timeout_ms": gAppConfig.TAFTimeoutMs,
530+
"taf_bin_duration": gAppConfig.TAFBinDuration,
531+
"taf_allow_slow_every_x": gAppConfig.TAFAllowSlowEveryX,
532+
"taf_normally_slow_count": gAppConfig.TAFNormallySlowCount,
514533
},
515534
"BIND-EVICTION": {
516535
"child.executable": gAppConfig.ChildExecutable,
@@ -551,24 +570,42 @@ func LogOccConfigs() {
551570
"max_desire_healthy_worker_pct": gAppConfig.MaxDesiredHealthyWorkerPct,
552571
},
553572
"R-W-SPLIT": {
554-
"readonly_children_pct": gAppConfig.ReadonlyPct,
555-
"cfg_from_tns_override_rw_split": gAppConfig.CfgFromTnsOverrideRWSplit,
573+
"readonly_children_pct": gAppConfig.ReadonlyPct,
556574
},
557575
"RAC": {
558576
"management_table_prefix": gAppConfig.ManagementTablePrefix,
559577
"rac_sql_interval": gAppConfig.RacMaintReloadInterval,
560578
"rac_restart_window": gAppConfig.RacRestartWindow,
561579
},
562-
"NO-CATEGORY": {
580+
"GENERAL-CONFIGURATIONS": {
563581
"database_type": gAppConfig.DatabaseType, // Oracle = 0; MySQL=1; POSTGRES=2
564-
"cfg_from_tns": gAppConfig.CfgFromTns,
565582
"log_level": gOpsConfig.logLevel,
566583
"high_load_pct": gAppConfig.HighLoadPct,
567584
"init_limit_pct": gAppConfig.InitLimitPct,
568585
"num_standby_dbs": gAppConfig.NumStdbyDbs,
569586
},
587+
"ENABLE_CFG_FROM_TNS": {
588+
"cfg_from_tns": gAppConfig.CfgFromTns,
589+
"cfg_from_tns_override_num_shards": gAppConfig.CfgFromTnsOverrideNumShards,
590+
"cfg_from_tns_override_taf": gAppConfig.CfgFromTnsOverrideTaf,
591+
"cfg_from_tns_override_rw_split": gAppConfig.CfgFromTnsOverrideRWSplit,
592+
},
593+
"STATEMENT-CACHE": {
594+
"enable_cache": gAppConfig.EnableCache,
595+
"enable_heart_beat": gAppConfig.EnableHeartBeat,
596+
"enable_query_replace_nl": gAppConfig.EnableQueryReplaceNL,
597+
},
598+
"SESSION-VARIABLES": {
599+
"enable_session_variables": gAppConfig.EnableSessionVariables,
600+
},
601+
"BIND-HASH-LOGGING": {
602+
"enable_bind_hash_logging": gAppConfig.EnableBindHashLogging,
603+
},
604+
"KEEP-ALIVE": {
605+
"use_non_blocking": gAppConfig.UseNonBlocking,
606+
},
570607
}
571-
608+
calName := mux_config_cal_name
572609
for feature, configs := range whiteListConfigs {
573610
switch feature {
574611
case "BACKLOG":
@@ -595,17 +632,45 @@ func LogOccConfigs() {
595632
if gAppConfig.ReadonlyPct == 0 {
596633
continue
597634
}
598-
case "SOFT-EVICTION", "BIND-EVICTION":
635+
case "SATURATION-RECOVERY", "BIND-EVICTION":
599636
if GetSatRecoverThrottleRate() <= 0 {
600637
continue
601638
}
639+
case "SOFT-EVICTION":
640+
if GetSatRecoverThrottleRate() <= 0 && gAppConfig.SoftEvictionProbability <= 0 {
641+
continue
642+
}
602643
case "MANUAL-RATE-LIMITER":
603644
if !gAppConfig.EnableQueryBindBlocker {
604645
continue
605646
}
647+
case "ENABLE_CFG_FROM_TNS":
648+
if !gAppConfig.CfgFromTns {
649+
continue
650+
}
651+
case "STATEMENT-CACHE":
652+
if !gAppConfig.EnableCache {
653+
continue
654+
}
655+
calName = oracle_worker_config_cal_name
656+
case "SESSION-VARIABLES":
657+
if !gAppConfig.EnableSessionVariables {
658+
continue
659+
}
660+
calName = oracle_worker_config_cal_name
661+
case "BIND-HASH-LOGGING":
662+
if !gAppConfig.EnableBindHashLogging {
663+
continue
664+
}
665+
calName = oracle_worker_config_cal_name
666+
case "KEEP-ALIVE":
667+
if !gAppConfig.UseNonBlocking {
668+
continue
669+
}
670+
calName = oracle_worker_config_cal_name
606671
}
607672

608-
evt := cal.NewCalEvent("OCC_CONFIG", fmt.Sprintf(feature), cal.TransOK, "")
673+
evt := cal.NewCalEvent(calName, fmt.Sprintf(feature), cal.TransOK, "")
609674
for cfg, val := range configs {
610675
s := fmt.Sprintf("%v", val)
611676
evt.AddDataStr(cfg, s)

0 commit comments

Comments
 (0)