pingcap / tidb-operator

TiDB operator creates and manages TiDB clusters running in Kubernetes.
https://docs.pingcap.com/tidb-in-kubernetes/
Apache License 2.0
1.22k stars 489 forks source link

Avoid using temporary storage of slow-log tailer #4340

Open aylei opened 2 years ago

aylei commented 2 years ago

Feature Request

Is your feature request related to a problem? Please describe:

Currently, the slow-log tailer requires the tidb-server output slow logs to a temporary dir and tail it to its STDOUT. However, this approach would consume ephemeral storage and may cause tidb-server being evicted under Disk Pressure.

Describe the feature you'd like:

Use pipe to transfer the slow log instead:

# tidb process
> mkfifo slow.log
> ./tidb-server --log-slow-query slow.log

# slow log tailer
> cat slow.log

Pipe does not consume any filesystem storage. We may lose slow logs if the tailer is abnormal, but this can hardly happen since the tailer is as simple as a single cat process.

Describe alternatives you've considered:

N/A

Teachability, Documentation, Adoption, Migration Strategy:

This would be change that requires rolling-restart of tidb-servers, if we think rolling-restarting tidb-servers should be avoided when upgrading tidb-operator, we can add an feature-gate and let the user enable is actively.

DanielZhangQD commented 2 years ago

@aylei Is mkfifo a good way to print the logs in a container? What about we suggest using a PV for the slow log?

yiduoyunQ commented 2 years ago

if #25716 to be fixed, is this still a potential problem?