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

Add log_queries_min_type to filter which entries will be written to query_log #10053

Merged
merged 1 commit into from
Apr 12, 2020

Conversation

azat
Copy link
Collaborator

@azat azat commented Apr 4, 2020

Changelog category (leave one):

  • New Feature

Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):
Add log_queries_min_type to filter which entries will be written to query_log

Detailed description / Documentation draft:
Can be used to write into query_log only failed queries (i.e. on memory
exceeded error), by using:

  set log_queries_min_type='EXCEPTION_WHILE_PROCESSING'

@alexey-milovidov
Copy link
Member

alexey-milovidov commented Apr 7, 2020

There is no assumed order in values of type.
It's only a coincidence that it looks useful.

@alexey-milovidov
Copy link
Member

Current solution does not look practical.

@azat
Copy link
Collaborator Author

azat commented Apr 7, 2020

Current solution does not look practical.

Ok, how about making enum of the following possible values in settings?

  • all (query + exception)
  • query (query_start + query_finish)
  • query_start
  • query_finish
  • exception (exception_before_start + exception_before_processing)
  • exception_before_start
  • exception_before_processing

@alexey-milovidov
Copy link
Member

alexey-milovidov commented Apr 8, 2020

Ok, how about making enum of the following possible values in settings?

Almost Ok. We have to made setting values consistent with Enum values in system.query_log (QueryFinish instead of query_finish).
But this solution looks too heavy for this task and it will be over complicated. Need to think more...
And it's strange if I cannot simply list all values that I want to see.

If the user really wants to get this feature, they can use Null engine for system.query_log and create a meterialized view on top of it. Maybe it's enough?

@alexey-milovidov
Copy link
Member

PS. Please don't worry about "spam" assigments by Ivan Blinkov. He has written a script that assigns pull request to random people. We decided that we will remove this script but Ivan has not stopped it yet.

@azat
Copy link
Collaborator Author

azat commented Apr 8, 2020

If the user really wants to get this feature, they can use Null engine for system.query_log and create a meterialized view on top of it. Maybe it's enough?

For some uses cases - yes, but it will not allow to change the type without recreating the table.

Why I found this useful is:

  • you can limit amount of information that goes to query_log (excluding QueryStart or even enable Exception* on prod globally)
  • you still want sometimes to debug the query completely (i.e. write all stages).
  • this can be more-or-less hot path (for example if you set it to Exception* then non will be written unless you have some errors, but with views it will need to filter blocks always, maybe this will be insignificant, but anyway does not sounds like the thing that you should do on production globally to me).

PS. Please don't worry about "spam" assigments by Ivan Blinkov. He has written a script that assigns pull request to random people. We decided that we will remove this script but Ivan has not stopped it yet.

P.S. I knew it! (since it tags the PR as soon as it has been submitted).

@blinkov blinkov removed their assignment Apr 9, 2020
@azat
Copy link
Collaborator Author

azat commented Apr 10, 2020

And it's strange if I cannot simply list all values that I want to see.

I can add parsing of a string, i.e. log_queries_type="QUERY_FINISH EXCEPTION_WHILE_PROCESSING", but this also does not looks good (at least to me), and making this at least more convenient to user I guess (but I'm open to any suggestions, maybe you know better ways to do this...)

P.S. at first I wanted to log only errors, but when I was writing the patch I decided to excluding say QUERY_START also can be useful

@alexey-milovidov
Copy link
Member

alexey-milovidov commented Apr 12, 2020

Ok.

Let's make it as simple as possible.
Let's name the setting log_queries_min_type and it will take numeric values. We will not validate these values. And simply apply this setting by comparison.

Reason: this will make the implementation of this setting obvious (that it compares numeric values of type).

@azat azat changed the title Add log_queries_type to filter which entries will be written to query_log Add log_queries_min_type to filter which entries will be written to query_log Apr 12, 2020
…uery_log

Can be used to write into query_log only failed queries (i.e. on memory
exceeded error), by using:

  set log_queries_min_type='EXCEPTION_WHILE_PROCESSING'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr-feature Pull request with new product feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants