Bug #88937 mysql client history file grows without bounds, slows down connecting to server

Submitted: 15 Dec 2017 11:27 Modified: 19 Dec 2017 11:47
Reporter: Riccardo Pizzi Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Logging Severity:S3 (Non-critical)
Version:5.6.38, 5.7.20 OS:Any
Assigned to: CPU Architecture:Any

[15 Dec 2017 11:27] Riccardo Pizzi
Description:
The file .mysql_history created by the mysql client seems to grow without bounds. 
When its size becomes important (> 100MB), connecting to a server with the client becomes slow, and the slowness increases with history file size.

This also happens at logout time, when the client has to update the history - I would expect the client to only append to it and this should be fast, however it is re-reading the entire file for some reason, which seems sub-optimal.

How to repeat:
Create a huge .mysql_history file with the following script:

echo "select 1" > file.txt; for i in {1..24}; do cat file.txt file.txt > file2.txt && mv file2.txt file.txt; done; mv file.txt .mysql_history

Try to connect to localhost:

mysql -u user -p ....

Wait several seconds (depending on speed of your home directory's storage) before getting a prompt

Suggested fix:
Limit the history file to a rotation of, let's say, last 5000 statements or so (maybe make that number configurable)
[19 Dec 2017 11:47] MySQL Verification Team
Hello Riccardo Pizzi,

Thank you for the report and feedback.
Observed the delay while connecting/disconnecting when .mysql_history file size was large(>100Mb delay is noticeable). 

Thanks,
Umesh

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.039 sec. using MySQL 8.4.7-u6-cloud

Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.