Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

slowLogTailer: rotated slow logs not cleaned #1779

Closed
aylei opened this issue Feb 26, 2020 · 6 comments · Fixed by #2045
Closed

slowLogTailer: rotated slow logs not cleaned #1779

aylei opened this issue Feb 26, 2020 · 6 comments · Fixed by #2045
Assignees
Labels
priority:P3 type/bug Something isn't working
Milestone

Comments

@aylei
Copy link
Contributor

aylei commented Feb 26, 2020

Bug Report

What version of TiDB Operator are you using?

v1.0.6

What's the status of the TiDB cluster pods?

NAME                            READY   STATUS    RESTARTS   AGE
db-discovery-65d54bbb55-zp272   1/1     Running   0          10h
db-monitor-669c96fb55-x2h75     3/3     Running   0          11h
db-pd-0                         1/1     Running   0          11h
db-pd-1                         1/1     Running   0          11h
db-pd-2                         1/1     Running   0          11h
db-tidb-0                       2/2     Running   0          4h28m
db-tidb-1                       2/2     Running   0          4h28m
db-tikv-0                       1/1     Running   0          11h
db-tikv-1                       1/1     Running   0          11h
db-tikv-2                       1/1     Running   0          11h

What did you do?

Load data to tidb cluster.

What did you expect to see?
Load data succeed

What did you see instead?
Load data failed because TiDB Pods were evicted to reclaim ephemeral storage:

image

And it turns out the slow log consumed a lot of ephemeral storage, whereas the tailer does not rotate the slow log:

/var/log/tidb # du -sh ./*
70.8M	./slowlog
299.9M	./slowlog-2020-02-26T02-10-16.452
299.9M	./slowlog-2020-02-26T02-11-33.170
299.9M	./slowlog-2020-02-26T02-12-27.762
299.9M	./slowlog-2020-02-26T02-13-44.140
299.9M	./slowlog-2020-02-26T02-16-08.322
299.9M	./slowlog-2020-02-26T02-18-27.989
300.0M	./slowlog-2020-02-26T02-22-49.095
300.0M	./slowlog-2020-02-26T02-26-00.591
299.9M	./slowlog-2020-02-26T02-29-03.809
299.9M	./slowlog-2020-02-26T02-31-16.241
299.9M	./slowlog-2020-02-26T02-32-11.446
300.0M	./slowlog-2020-02-26T02-33-12.131
300.0M	./slowlog-2020-02-26T02-34-16.872
299.9M	./slowlog-2020-02-26T02-35-14.501
299.9M	./slowlog-2020-02-26T02-38-52.075
300.0M	./slowlog-2020-02-26T02-43-13.551
299.9M	./slowlog-2020-02-26T02-49-34.426
299.9M	./slowlog-2020-02-26T02-53-30.816
299.9M	./slowlog-2020-02-26T02-54-38.124
299.9M	./slowlog-2020-02-26T02-55-52.087
300.0M	./slowlog-2020-02-26T03-02-16.277
299.9M	./slowlog-2020-02-26T03-07-40.269
@aylei aylei added the type/bug Something isn't working label Feb 26, 2020
@Yisaer Yisaer self-assigned this Feb 26, 2020
@Yisaer
Copy link
Contributor

Yisaer commented Feb 26, 2020

@aylei @cofyc I found that the busybox we used in the tidb sidecar didn't have logrotate command. What's your opinion to logrotate slowlog file?

@cofyc
Copy link
Contributor

cofyc commented Feb 26, 2020

the log file is already rotated by tidb periodically. is it possible to configure tidb to discard or limit the total size of rotated log files? otherwise, we need to delete them ourselves. we can use rm to remove them, the problem is we need to update the command of slow log tailer container which will trigger a rolling upgrade.

@cofyc cofyc added this to the v1.1.0 milestone Feb 26, 2020
@cofyc cofyc changed the title slowLogTailer does not rotate slow logs slowLogTailer: rotated slow logs not cleaned Feb 26, 2020
@aylei
Copy link
Contributor Author

aylei commented Mar 4, 2020

Yes, I misphrase the problem. I've not found any configurations about cleaning rotated logs

@Yisaer
Copy link
Contributor

Yisaer commented Mar 27, 2020

It seems we could use max-size and max-backup configuration in tidb-server. This would limit the total storage usage of the log.
ref: https://pingcap.com/docs-cn/stable/reference/configuration/tidb-server/configuration-file/#max-size
https://pingcap.com/docs-cn/stable/reference/configuration/tidb-server/configuration-file/#max-backups

@cofyc
Copy link
Contributor

cofyc commented Mar 27, 2020

that's great! it's good practice to collect the slow logs to other places, e.g. elasticsearch. maybe we can limit the max-backup to a reasonable value in the cloud by default. this is the same as if we're going to clean the logs for the user.

@Yisaer
Copy link
Contributor

Yisaer commented Mar 27, 2020

Yes, I think maybe we could set a reasonable default value for max-size and max-backup for tidb considering the ephemeral storage.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority:P3 type/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants