-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
cli/sql: put a limit on history size #88173
Conversation
Thank you. Can you add a bytes limit too please if it's a bytes limit issues? |
No. There's no such thing inside libedit. No interest in extending this now we have #86457 in the pipeline. |
FWIW shells (bash, zsh etc) also use a line count, not a byte count. |
Previously, there was no limit. Some users managed to make their history run into megabyte-size, despite de-duplication, which was causing slowness. This patch fixes it by adding a limit of 1000 entries. Sufficiently large to not be inconvenient, but sufficiently small that it prevents the history file from growing abnormally large. Release note (cli change): The interactive SQL shell now retains a maximum of 1000 entries. There was no limit previously.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if the de-duplication is entirely working as expected - I'm able to grow the log up to 100KB by just running tpch Q2 many times (and could probably grow further if I kept going). Running the same query with different limits grows the log even faster - I got up to ~10MB that way - and running completely different queries would probably grow it faster still. This change truncates the later case down to <2MB, so I think it's a good improvement even if it doesn't totally fix the problem.
Reviewable status: complete! 1 of 0 LGTMs obtained
That does not make sense to me. When you run a SQL input file with the shell, no entry should be added to the history! Can you show us what is the precise command you run? |
I was copy-pasting into the interactive session rather than using
Now that I'm trying again, it doesn't always happen - running the same query repeatedly and waiting for each previous one to finish before pasting the next and hitting enter does not cause the log to grow, as expected. However, I found two cases that do cause it to grow: pasting and hitting enter before the previous run returns, and alternating between two queries. For the first case it was easier to do tpch Q5 than Q2 because it takes longer to return (running against a tpch db obviously):
For the second I just alternated between Both cases cause a consistent increase in log size on each iteration. The second case seems more serious than the first, since it seems to indicate that the de-duplication isn't working over the whole history as expected. Maybe de-duplication over the entire history only happens occasionally, and the trigger condition isn't being met? I did notice during some of the tests that the log size would shrink significantly before growing again, but it didn't seem consistent or predictable... |
For that first case (pasting and running before previous one completes) I was able to reproduce with this statement:
but not this one:
Going back through the history with the up arrow shows that the successful reproduction executes the second time looking like this:
So I think the first case is just a special case of the second since it causes the query to alternate between a newline and |
thanks for explaining! indeed, the de-dup as implemented only de-dups the last entries. So this explains it. bors r=DrewKimball |
Build failed: |
unrelated flake #88249 bors r=DrewKimball |
Build succeeded: |
Fixes #54679.
Previously, there was no limit. Some users managed to make their history run into megabyte-size, despite de-duplication, which was causing slowness.
This patch fixes it by adding a limit of 1000 entries. Sufficiently large to not be inconvenient, but sufficiently small that it prevents the history file from growing abnormally large.
Release note (cli change): The interactive SQL shell now retains a maximum of 1000 entries. There was no limit previously.