Dynamic modification of configuration files&&Slow log - #2103
Merged
AlexStocks merged 3 commits intoNov 8, 2023
Conversation
…the functionality.
AlexStocks
reviewed
Nov 6, 2023
AlexStocks
reviewed
Nov 6, 2023
AlexStocks
reviewed
Nov 6, 2023
| w := bufio.NewWriter(f) | ||
|
|
||
| for _, item := range c.items { | ||
| var lineStr string |
AlexStocks
reviewed
Nov 7, 2023
AlexStocks
reviewed
Nov 7, 2023
| ` | ||
|
|
||
| type Config struct { | ||
| ConfigFileName string `toml:"-" json:"config_file_name"` |
Contributor
There was a problem hiding this comment.
1 照配置文件中的顺序放置这些成员,不要上来就放到最上面。
2 为何下面三个成员没有 json?
AlexStocks
reviewed
Nov 7, 2023
| } | ||
|
|
||
| func getWholeCmd(multi []*redis.Resp, cmd []byte) int { | ||
| var index = 0 |
Contributor
There was a problem hiding this comment.
var (
index = 0
bytes = 0
)
AlexStocks
reviewed
Nov 7, 2023
| } | ||
| bytes += len(multi[i].Value) | ||
|
|
||
| // 如果cmd已经满了,那么最后腾出来一个more长度的位置添加more信息 |
AlexStocks
reviewed
Nov 7, 2023
| "os" | ||
| "os/exec" | ||
| "path/filepath" | ||
| "pika/codis/v2/pkg/proxy/redis" |
Contributor
There was a problem hiding this comment.
注意下 import 里面这些包路径的顺序,把这行放到 import 最下面
AlexStocks
reviewed
Nov 7, 2023
AlexStocks
reviewed
Nov 7, 2023
AlexStocks
reviewed
Nov 7, 2023
| 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 { |
AlexStocks
reviewed
Nov 7, 2023
|
|
||
| r.Resp = SlowLogGetByNum(num) | ||
| } else if len(r.Multi) == 4 { | ||
| var id int64 |
Contributor
There was a problem hiding this comment.
var (
id int64
num int64
err error
)
AlexStocks
reviewed
Nov 7, 2023
AlexStocks
reviewed
Nov 7, 2023
| PIKA_SLOWLOG_LENGTH_MAX = 10000000 | ||
| ) | ||
|
|
||
| type Mutex struct { |
AlexStocks
reviewed
Nov 7, 2023
| num = int64(PSlowLog.logList.Len()) | ||
| } | ||
| var res = make([]*redis.Resp, 0, num) | ||
| var iter = PSlowLog.logList.Front() // 从最新的数据开始 |
AlexStocks
reviewed
Nov 7, 2023
| return err | ||
| } | ||
|
|
||
| // 拿到一行并去除两边空白字符 |
AlexStocks
reviewed
Nov 7, 2023
| for i := 0; i < obj.NumField(); i++ { | ||
| fieldInfo := obj.Type().Field(i) | ||
| name := fieldInfo.Tag.Get("toml") | ||
| // 检查字段的toml tag是否合法 |
AlexStocks
reviewed
Nov 7, 2023
| log.Infof("Show config, len = %d\n", len(c.items)) | ||
| for index, item := range c.items { | ||
| if item.confType == TypeComment { | ||
| // 注释的格式: id: context |
AlexStocks
reviewed
Nov 7, 2023
| // 注释的格式: id: context | ||
| log.Infof("%d: %s\n", index, item.name) | ||
| } else { | ||
| // 配置文件的格式: id: key = value 或者 id: key value |
dingxiaoshuai123
force-pushed
the
codis_slow_log
branch
from
November 7, 2023 07:13
55c5e46 to
8f9451e
Compare
AlexStocks
reviewed
Nov 7, 2023
| } | ||
| } | ||
|
|
||
| func (s *Proxy) ConfigSet(key, value string) *redis.Resp { |
AlexStocks
reviewed
Nov 7, 2023
| type DeployConfig struct { | ||
| items []*ConfItem | ||
| confMap map[string]*ConfItem | ||
| sep string //配置项中key、value分隔符 |
dingxiaoshuai123
force-pushed
the
codis_slow_log
branch
from
November 8, 2023 06:51
7a045a7 to
864988a
Compare
dingxiaoshuai123
force-pushed
the
codis_slow_log
branch
from
November 8, 2023 07:07
864988a to
f19eab2
Compare
AlexStocks
approved these changes
Nov 8, 2023
| if found { | ||
| item.value = value | ||
| } else { | ||
| item := &ConfItem{} |
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.