Skip to content

Commit

Permalink
Dynamically modify Codis configuration file and add slow query logs.
Browse files Browse the repository at this point in the history
  • Loading branch information
dingxiaoshuai123 committed Nov 8, 2023
1 parent 8f9451e commit f19eab2
Show file tree
Hide file tree
Showing 6 changed files with 195 additions and 191 deletions.
3 changes: 1 addition & 2 deletions codis/pkg/proxy/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,6 @@ metrics_report_statsd_prefix = ""
`

type Config struct {
ConfigFileName string `toml:"-" json:"config_file_name"`

ProtoType string `toml:"proto_type" json:"proto_type"`
ProxyAddr string `toml:"proxy_addr" json:"proxy_addr"`
AdminAddr string `toml:"admin_addr" json:"admin_addr"`
Expand Down Expand Up @@ -197,6 +195,7 @@ type Config struct {
MetricsReportStatsdServer string `toml:"metrics_report_statsd_server" json:"metrics_report_statsd_server"`
MetricsReportStatsdPeriod timesize.Duration `toml:"metrics_report_statsd_period" json:"metrics_report_statsd_period"`
MetricsReportStatsdPrefix string `toml:"metrics_report_statsd_prefix" json:"metrics_report_statsd_prefix"`
ConfigFileName string `toml:"-" json:"config_file_name"`
}

func NewDefaultConfig() *Config {
Expand Down
13 changes: 7 additions & 6 deletions codis/pkg/proxy/mapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ func init() {
{"BLPOP", FlagWrite | FlagNotAllow},
{"BRPOP", FlagWrite | FlagNotAllow},
{"BRPOPLPUSH", FlagWrite | FlagNotAllow},
{"CCONFIG", FlagWrite},
{"CLIENT", FlagNotAllow},
{"CLUSTER", FlagNotAllow},
{"COMMAND", 0},
Expand Down Expand Up @@ -216,7 +215,7 @@ func init() {
{"SLOTSRESTORE-ASYNC-AUTH", FlagWrite | FlagNotAllow},
{"SLOTSRESTORE-ASYNC-ACK", FlagWrite | FlagNotAllow},
{"SLOTSSCAN", FlagMasterOnly},
{"SLOWLOG", 0},
{"SLOWLOG", FlagNotAllow},
{"SMEMBERS", 0},
{"SMOVE", FlagWrite},
{"SORT", FlagWrite},
Expand All @@ -230,6 +229,8 @@ func init() {
{"SUNION", 0},
{"SUNIONSTORE", FlagWrite},
{"SYNC", FlagNotAllow},
{"PCONFIG", 0},
{"PSLOWLOG", 0},
{"TIME", FlagNotAllow},
{"TOUCH", FlagWrite},
{"TTL", 0},
Expand Down Expand Up @@ -322,9 +323,10 @@ func getHashKey(multi []*redis.Resp, opstr string) []byte {
}

func getWholeCmd(multi []*redis.Resp, cmd []byte) int {
var index = 0
var bytes = 0

var (
index = 0
bytes = 0
)
for i := 0; i < len(multi); i++ {
if index < len(cmd) {
index += copy(cmd[index:], multi[i].Value)
Expand All @@ -334,7 +336,6 @@ func getWholeCmd(multi []*redis.Resp, cmd []byte) int {
}
bytes += len(multi[i].Value)

// 如果cmd已经满了,那么最后腾出来一个more长度的位置添加more信息
if i == len(multi)-1 && index == len(cmd) {
more := []byte("... " + strconv.Itoa(len(multi)) + " elements " + strconv.Itoa(bytes) + " bytes.")
index = len(cmd) - len(more)
Expand Down
Loading

0 comments on commit f19eab2

Please sign in to comment.