Skip to content

Conversation

NaNShaner
Copy link
Contributor

'slowlog-log-slower-than' and 'slowlog-max-len', have been added to the configuration file.

// SlowLogger Slow query logger
type SlowLogger struct {
mu sync.RWMutex
entries *list.List // 日志链表
Copy link
Owner

Choose a reason for hiding this comment

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

既然知道最大长度建议还是搞环形数组,链表会比较慢

// 记录一个慢查询
start := time.Now()
time.Sleep(2 * time.Millisecond) // 确保超过阈值
logger.Record(start, [][]byte{[]byte("GET"), []byte("key1")}, "127.0.0.1:12345")
Copy link
Owner

Choose a reason for hiding this comment

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

utils.ToCmdLine


exec := selectedDB.Exec(c, cmdLine)
// Record slow query logs
server.slogLogger.Record(GodisExecCommandStartUnixTime, cmdLine, c.Name())
Copy link
Owner

Choose a reason for hiding this comment

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

GodisExecCommandStartUnixTime 为什么要搞成全局变量?在 Exec 函数里加个局部变量不是已经够用了?而且 godis 内核是并行的,这么搞全局变量不会出错吗?

@NaNShaner
Copy link
Contributor Author

好的, 我修改一下。

@NaNShaner NaNShaner closed this Jun 30, 2025
@NaNShaner NaNShaner deleted the feat/addSlowlogCommand branch June 30, 2025 13:05
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