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 InitialQuery event #58195

Merged
merged 10 commits into from Feb 13, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions src/Common/ProfileEvents.cpp
Expand Up @@ -8,6 +8,7 @@
M(Query, "Number of queries to be interpreted and potentially executed. Does not include queries that failed to parse or were rejected due to AST size limits, quota limits or limits on the number of simultaneously running queries. May include internal queries initiated by ClickHouse itself. Does not count subqueries.") \
M(SelectQuery, "Same as Query, but only for SELECT queries.") \
M(InsertQuery, "Same as Query, but only for INSERT queries.") \
M(InitialQuery, "Same as Query, but only counts initial queries (see is_initial_query).")\
M(QueriesWithSubqueries, "Count queries with all subqueries") \
M(SelectQueriesWithSubqueries, "Count SELECT queries with all subqueries") \
M(InsertQueriesWithSubqueries, "Count INSERT queries with all subqueries") \
Expand Down
7 changes: 5 additions & 2 deletions src/Databases/DatabaseReplicatedWorker.cpp
Expand Up @@ -6,7 +6,10 @@
#include <filesystem>

namespace fs = std::filesystem;

namespace ProfileEvents
{
extern const Event InitialQuery;
}
namespace DB
{

Expand Down Expand Up @@ -264,7 +267,7 @@ String DatabaseReplicatedDDLWorker::tryEnqueueAndExecuteEntry(DDLLogEntry & entr
chassert(!task->entry.query.empty());
assert(!zookeeper->exists(task->getFinishedNodePath()));
task->is_initial_query = true;

ProfileEvents::increment(ProfileEvents::InitialQuery);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not the only place where it is set.
Better, check executeQuery.cpp

LOG_DEBUG(log, "Waiting for worker thread to process all entries before {}", entry_name);
UInt64 timeout = query_context->getSettingsRef().database_replicated_initial_query_timeout_sec;
{
Expand Down
@@ -0,0 +1 @@
InitialQuery 6 Same as Query, but only counts initial queries (see is_initial_query).
1 change: 1 addition & 0 deletions tests/queries/0_stateless/02950_initialquery_event.sql
@@ -0,0 +1 @@
SELECT * FROM system.events where event = 'InitialQuery'