CNDB-15260: Add SAI-specific details to slow query logger #2044
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What is the issue
The slow query logger is one of the most useful tools when dealing with performance-related incidents. Currently it simply prints the CQL representation of the slow query and its running time. So while it can allow us to identify problematic SAI queries, we have to go to the aggregated metrics where it's difficult to see what matches the problematic query.
I think it would be useful if the slow query logger also printed the SAI query metrics and plan. That way we could examine log records at the time of the incident to see what's going on with individual slow queries, without needing to extract conclusions from aggregated metrics.
What does this PR fix and why was it fixed
This PR adds SAI-specific information to the log messages produced when slow queries are detected. That information consists on the metrics in the
QueryContext
and the tree view of the queryPlan
. There is acassandra.cassandra.sai.slow_query_log.details_enabled
property to disable this extended logging.This is how slow queries are currently logged:
And this is how they would look like with SAI details:
Note that the queries are printed as invalid CQL and include user data. That is being dealt with in CNDB-15280, which is under review.