ccfos / nightingale

An all-in-one observability solution which aims to combine the advantages of Prometheus and Grafana. It manages alert rules and visualizes metrics, logs, traces in a beautiful web UI.
https://flashcat.cloud/docs/
Apache License 2.0
9.42k stars 1.38k forks source link

更改task_host表中字段stdout stderr的类型为mediumtext #2027

Closed rayn316 closed 1 month ago

rayn316 commented 1 month ago

What type of PR is this? task

What this PR does / why we need it: 当执行的任务日志大于mysql text类型容量时,n9e写入会出现错误error from server: Error 1366: Incorrect string value 将task表的类型更改为更大的类型mediumtext,解决稍微大一点的日志无法记录和太大日志写入导致磁盘占用疯涨

Which issue(s) this PR fixes: 更改task_host表中stdout stderr的类型为mediumtext 任务日志容量从text 64k大小改为mediumtext 16m大小

Fixes #

Special notes for your reviewer:

UlricQin commented 1 month ago

改类型不是很好,太大的输出容易打爆DB。如果某个用户搞了一个输出内容很大的task,就容易影响平台其他用户。实际上我看Categraf的代码中是有长度限制的:https://github.com/flashcatcloud/categraf/blob/main/ibex/tasks.go#L34 如果输出的内容太长会截断。不清楚这个逻辑为何没有生效。可能是因为DB的charset从Latin1改成了utf8mb4的缘故,而Categraf中的长度限制还是写的 65535,这里最好是改一下Categraf的代码,把代码中 65535 改成 16384 就可以了

rayn316 commented 1 month ago

会不会是截断后刚好把中文截断成乱码了,所以写不进去

UlricQin commented 1 month ago

会不会是截断后刚好把中文截断成乱码了,所以写不进去

我看了一下代码,代码里用的是byte,而非golang rune 类型,可能就是你说的原因。我测试一下,如果有问题我修复一下。

UlricQin commented 1 month ago

https://github.com/flashcatcloud/categraf/commit/e84edc7a1fa925b52ed77b9cc0950c1a7ed999e1 我提了一个 PR 理论上可以修复字符乱码以及字符太多无法写入DB的问题,你要是有环境的话可以编译测试一下。

rayn316 commented 1 month ago

好吧,我先关闭此提交,有时间我会使用新版本测试