Skip to content

Dynamic modification of configuration files&&Slow log - #2103

Merged
AlexStocks merged 3 commits into
OpenAtomFoundation:unstablefrom
dingxiaoshuai123:codis_slow_log
Nov 8, 2023
Merged

Dynamic modification of configuration files&&Slow log#2103
AlexStocks merged 3 commits into
OpenAtomFoundation:unstablefrom
dingxiaoshuai123:codis_slow_log

Conversation

@dingxiaoshuai123

@dingxiaoshuai123 dingxiaoshuai123 commented Nov 6, 2023

Copy link
Copy Markdown
Collaborator

Related issue : #2086
1.Add the Codis config command for dynamic configuration at the Codis level.
2. Add slow logging at the Codis level to record commands that exceed the execution time threshold.

Comment thread codis/pkg/utils/configAux.go Outdated
Comment thread codis/pkg/utils/configAux.go
Comment thread codis/pkg/utils/configAux.go Outdated
w := bufio.NewWriter(f)

for _, item := range c.items {
var lineStr string

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

放到for循环外面

@AlexStocks AlexStocks changed the title [wip]Dynamic modification of configuration files. Dynamic modification of configuration files. Nov 7, 2023
Comment thread codis/cmd/proxy/main.go
Comment thread codis/pkg/proxy/config.go Outdated
`

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 照配置文件中的顺序放置这些成员,不要上来就放到最上面。
2 为何下面三个成员没有 json?

Comment thread codis/pkg/proxy/mapper.go Outdated
}

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

var (
index = 0
bytes = 0
)

Comment thread codis/pkg/proxy/mapper.go Outdated
}
bytes += len(multi[i].Value)

// 如果cmd已经满了,那么最后腾出来一个more长度的位置添加more信息

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

改成英文

Comment thread codis/pkg/proxy/proxy.go Outdated
"os"
"os/exec"
"path/filepath"
"pika/codis/v2/pkg/proxy/redis"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

注意下 import 里面这些包路径的顺序,把这行放到 import 最下面

Comment thread codis/pkg/proxy/proxy.go Outdated
Comment thread codis/pkg/proxy/proxy.go Outdated
Comment thread codis/pkg/proxy/session.go Outdated
log.Errorf("%s remote:%s, start_time(us):%d, duration(us): [%d, %d, %d], %d, tasksLen:%d",
time.Unix(r.ReceiveTime/1e9, 0).Format("2006-01-02 15:04:05"), s.Conn.RemoteAddr(), r.ReceiveTime/1e3, d0, d1, d2, duration, r.TasksLen)
}
//if s.config.SlowlogLogSlowerThan > 0 {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

为何注释掉?

Comment thread codis/pkg/proxy/session.go Outdated

r.Resp = SlowLogGetByNum(num)
} else if len(r.Multi) == 4 {
var id int64

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

var (
       id int64
	num int64
		 err error

)

Comment thread codis/pkg/proxy/slowlog.go
Comment thread codis/pkg/proxy/slowlog.go Outdated
PIKA_SLOWLOG_LENGTH_MAX = 10000000
)

type Mutex struct {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这种封装有何意义?

Comment thread codis/pkg/proxy/slowlog.go Outdated
num = int64(PSlowLog.logList.Len())
}
var res = make([]*redis.Resp, 0, num)
var iter = PSlowLog.logList.Front() // 从最新的数据开始

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

后面的注释改成英文

Comment thread codis/pkg/utils/configAux.go Outdated
return err
}

// 拿到一行并去除两边空白字符

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

注释全部改成英文

Comment thread codis/pkg/utils/configAux.go Outdated
for i := 0; i < obj.NumField(); i++ {
fieldInfo := obj.Type().Field(i)
name := fieldInfo.Tag.Get("toml")
// 检查字段的toml tag是否合法

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

改成英文注释

Comment thread codis/pkg/utils/configAux.go Outdated
log.Infof("Show config, len = %d\n", len(c.items))
for index, item := range c.items {
if item.confType == TypeComment {
// 注释的格式: id: context

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

改成英文注释

Comment thread codis/pkg/utils/configAux.go Outdated
// 注释的格式: id: context
log.Infof("%d: %s\n", index, item.name)
} else {
// 配置文件的格式: id: key = value 或者 id: key value

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

改成英文注释

Comment thread codis/pkg/proxy/proxy.go Outdated
}
}

func (s *Proxy) ConfigSet(key, value string) *redis.Resp {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s 统一改成 p

Comment thread codis/pkg/utils/configAux.go Outdated
type DeployConfig struct {
items []*ConfItem
confMap map[string]*ConfItem
sep string //配置项中key、value分隔符

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

英文注释

@dingxiaoshuai123 dingxiaoshuai123 changed the title Dynamic modification of configuration files. Dynamic modification of configuration files&&Slow log Nov 8, 2023
Comment thread codis/pkg/utils/configAux.go Outdated
if found {
item.value = value
} else {
item := &ConfItem{}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

构造函数内赋值

@AlexStocks
AlexStocks merged commit 8ed1123 into OpenAtomFoundation:unstable Nov 8, 2023
bigdaronlee163 pushed a commit to bigdaronlee163/pika that referenced this pull request Jun 8, 2024
…tion#2103)

* Dynamic modification of configuration files.Check the correctness of the functionality.

* Modified some specification issues.

* Dynamically modify Codis configuration file and add slow query logs.
cheniujh pushed a commit to cheniujh/pika that referenced this pull request Sep 24, 2024
…tion#2103)

* Dynamic modification of configuration files.Check the correctness of the functionality.

* Modified some specification issues.

* Dynamically modify Codis configuration file and add slow query logs.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants