Skip to content

Commit

Permalink
added sqlName for maint queries (#405)
Browse files Browse the repository at this point in the history
  • Loading branch information
venkatsridhar95 authored Nov 7, 2024
1 parent 1124f4b commit b94420d
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/querybindblocker.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ func loadBlockQueryBind(db *sql.DB) {
}

defer conn.Close()
q := fmt.Sprintf("SELECT /*queryBindBlocker*/ %ssqlhash, %ssqltext, bindvarname, bindvarvalue, blockperc, %smodule FROM %s_rate_limiter where %smodule='%s'", GetConfig().StateLogPrefix, GetConfig().StateLogPrefix, GetConfig().StateLogPrefix, GetConfig().ManagementTablePrefix, GetConfig().StateLogPrefix, g_module)
q := fmt.Sprintf("SELECT /*heraMgmt.QueryBindBlocker*/ %ssqlhash, %ssqltext, bindvarname, bindvarvalue, blockperc, %smodule FROM %s_rate_limiter where %smodule='%s'", GetConfig().StateLogPrefix, GetConfig().StateLogPrefix, GetConfig().StateLogPrefix, GetConfig().ManagementTablePrefix, GetConfig().StateLogPrefix, g_module)
logger.GetLogger().Log(logger.Info, "Loading query bind blocker meta-sql "+q)
stmt, err := conn.PrepareContext(ctx, q)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion lib/racmaint.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func racMaintMain(shard int, interval int, cmdLineModuleName string) {
tempKey.module = ""
prev[tempKey] = racRow
}
racSQL := fmt.Sprintf("/*shard=%d*/ SELECT inst_id, UPPER(status), status_time, UPPER(module) "+
racSQL := fmt.Sprintf("/*heraMgmt.racMaintShard=%d*/ SELECT inst_id, UPPER(status), status_time, UPPER(module) "+
"FROM %s_maint "+
"WHERE UPPER(machine) = ? and "+
"UPPER(module) in ( ?, ? ) "+ //IN ( UPPER(sys_context('USERENV', 'MODULE')), UPPER(sys_context('USERENV', 'MODULE') || '_TAF' ) ) "+
Expand Down
6 changes: 3 additions & 3 deletions lib/shardingcfg.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func GetWLCfg() *WLCfg {
func getSQL() string {
// TODO: add hostname in the comment
if len(GetConfig().ShardingPostfix) != 0 {
return fmt.Sprintf("SELECT scuttle_id, shard_id, read_status, write_status from %s_shard_map_%s where status = 'Y'", GetConfig().ManagementTablePrefix, GetConfig().ShardingPostfix)
return fmt.Sprintf("SELECT /*heraMgmt.Sharding*/ scuttle_id, shard_id, read_status, write_status from %s_shard_map_%s where status = 'Y'", GetConfig().ManagementTablePrefix, GetConfig().ShardingPostfix)
}
//TODO: is this still needed?
slowf := fmt.Sprintf("slow.%d", os.Getpid())
Expand All @@ -86,15 +86,15 @@ func getSQL() string {
n, err := f.Read(buf[:63])
if err == nil {
buf[n] = 0
sql := fmt.Sprintf("SELECT scuttle_id + usleep(%s) - %s, shard_id, read_status, write_status from %s_shard_map where status = 'Y'", string(buf), string(buf), GetConfig().ManagementTablePrefix)
sql := fmt.Sprintf("SELECT /*heraMgmt.Sharding*/ scuttle_id + usleep(%s) - %s, shard_id, read_status, write_status from %s_shard_map where status = 'Y'", string(buf), string(buf), GetConfig().ManagementTablePrefix)
if logger.GetLogger().V(logger.Warning) {
logger.GetLogger().Log(logger.Warning, "slow shard map query ", sql)
}
return sql
}
}
// if we get here, it means it can't get the slow query
return fmt.Sprintf("SELECT scuttle_id, shard_id, read_status, write_status from %s_shard_map where status = 'Y'", GetConfig().ManagementTablePrefix)
return fmt.Sprintf("SELECT /*heraMgmt.Sharding*/ scuttle_id, shard_id, read_status, write_status from %s_shard_map where status = 'Y'", GetConfig().ManagementTablePrefix)
}

/*
Expand Down

0 comments on commit b94420d

Please sign in to comment.