-
Notifications
You must be signed in to change notification settings - Fork 410
Flash: add MPP sql digest and connection metadata tracing #10751
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -77,6 +77,10 @@ void MPPTaskStatistics::initializeExecutorDAG(DAGContext * dag_context_) | |
|
|
||
| is_root = dag_context->isRootMPPTask(); | ||
| sender_executor_id = root_executor.executor_id(); | ||
| connection_id = dag_context->getConnectionID(); | ||
| connection_alias = dag_context->getConnectionAlias(); | ||
| sql_digest = dag_context->getSQLDigest(); | ||
| plan_digest = dag_context->getPlanDigest(); | ||
| executor_statistics_collector.initialize(dag_context); | ||
| } | ||
|
|
||
|
|
@@ -110,6 +114,7 @@ void MPPTaskStatistics::logTracingJson() | |
| /// don't use info log for initializing status since it does not contains too many information | ||
| status == INITIALIZING ? Poco::Message::PRIO_DEBUG : Poco::Message::PRIO_INFORMATION, | ||
| R"({{"query_tso":{},"task_id":{},"is_root":{},"sender_executor_id":"{}","executors":{},"host":"{}")" | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [P2] JSON tracing log builds JSON without escaping user-controlled fields Why: Evidence:
Fix: JSON-escape |
||
| R"(,"connection_id":{},"connection_alias":"{}","sql_digest":"{}","plan_digest":"{}")" | ||
JaySon-Huang marked this conversation as resolved.
Show resolved
Hide resolved
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This is useful to add sql_digest in the final report logging of For example, in the internal case of and tidb log by Loki query like If there are
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we log down the sql_digest in
If we only log down the sql_digest in
|
||
| R"(,"task_init_timestamp":{},"task_start_timestamp":{},"task_end_timestamp":{})" | ||
| R"(,"compile_start_timestamp":{},"compile_end_timestamp":{})" | ||
| R"(,"read_wait_index_start_timestamp":{},"read_wait_index_end_timestamp":{})" | ||
|
|
@@ -121,6 +126,10 @@ void MPPTaskStatistics::logTracingJson() | |
| sender_executor_id, | ||
| executor_statistics_collector.profilesToJson(), | ||
| host, | ||
| connection_id, | ||
| connection_alias, | ||
| sql_digest, | ||
| plan_digest, | ||
| toNanoseconds(task_init_timestamp), | ||
| toNanoseconds(task_start_timestamp), | ||
| toNanoseconds(task_end_timestamp), | ||
|
|
||
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.
[P0] Unbounded
sql_digestaccepted from gRPC can cause OOM/disk-fill DoSWhy:
sql_digestis accepted from gRPC without any length or format validation and is logged at INFO level before security checks (checkGrpcContextat line 504). With gRPC max receive size set to unlimited (SetMaxReceiveMessageSize(-1)inFlashGrpcServerHolder.cpp:172), a single malicious request can force very large allocations and log writes, potentially OOM-crashing the TiFlash process or rapidly consuming disk space.Evidence:
FlashService.cpp:488-503DAGContextwithout validation:DAGContext.cpp:107(sql_digest(meta_.sql_digest()))FlashGrpcServerHolder.cpp:1720.0.0.0:3930Fix: Enforce max size (e.g., 128 bytes) and expected pattern (fixed hex digest length) on
sql_digestbefore storing/logging. Truncate or hash if oversized.