Skip to content

Commit

Permalink
[BugFix] Fix load profile miss metrics "IndexNum" "ReplicatedStorage"…
Browse files Browse the repository at this point in the history
… "TxnID" (#46074)

Signed-off-by: PengFei Li <[email protected]>
  • Loading branch information
banmoy authored May 23, 2024
1 parent e586341 commit 8f6f6b3
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 0 deletions.
5 changes: 5 additions & 0 deletions be/src/exec/tablet_sink.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1096,6 +1096,11 @@ void OlapTableSink::_prepare_profile(RuntimeState* state) {
_client_rpc_timer = ADD_TIMER(_profile, "RpcClientSideTime");
_server_rpc_timer = ADD_TIMER(_profile, "RpcServerSideTime");
_server_wait_flush_timer = ADD_TIMER(_profile, "RpcServerWaitFlushTime");
_profile->add_info_string("TxnID", fmt::format("{}", _txn_id));
_profile->add_info_string("IndexNum", fmt::format("{}", _schema->indexes().size()));
_profile->add_info_string("ReplicatedStorage", fmt::format("{}", _enable_replicated_storage));
_alloc_auto_increment_timer = ADD_TIMER(_profile, "AllocAutoIncrementTime");
_profile->add_info_string("AutomaticPartition", fmt::format("{}", _enable_automatic_partition));
}

void OlapTableSink::set_profile(RuntimeProfile* profile) {
Expand Down
46 changes: 46 additions & 0 deletions test/sql/test_profile/R/test_load_profile
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
-- name: test_load_profile
CREATE TABLE `t0` (
`v1` int(11) NOT NULL,
`v2` int(11) NOT NULL,
`v3` int(11) NOT NULL
) ENGINE=OLAP
DUPLICATE KEY(`v1`)
DISTRIBUTED BY HASH(`v1`) BUCKETS 10
PROPERTIES (
"replication_num" = "1"
);
-- result:
-- !result
SET enable_profile="true";
-- result:
-- !result
INSERT INTO `t0` (v1, v2, v3) values
(1, 1, 1),
(1, 1, 2),
(1, 1, 3),
(1, 2, 4),
(1, 2, 5),
(1, 2, 6),
(2, 3, 7),
(2, 3, 8),
(2, 3, 9),
(2, 4, 10),
(2, 4, 11),
(2, 4, 12);
-- result:
-- !result
with
profile as (
select unnest as line from (values(1))t(v) join unnest(split(get_query_profile(last_query_id()), "\n") )
), result as (
select * from profile
where REGEXP(line, "- (RowsRead|RowsReturned|RowsFiltered|OpenTime|CloseWaitTime|PrepareDataTime)")
OR REGEXP(line, "- (ConvertChunkTime|ValidateDataTime|SendDataTime|PackChunkTime|SendRpcTime)")
OR REGEXP(line, "- (WaitResponseTime|SerializeChunkTime|CompressTime|RpcClientSideTime|RpcServerSideTime)")
OR REGEXP(line, "- (RpcServerWaitFlushTime|TxnID|IndexNum|ReplicatedStorage|AllocAutoIncrementTime)")
OR REGEXP(line, "- (AutomaticPartition)")
)
select count(*) from result;
-- result:
22
-- !result
40 changes: 40 additions & 0 deletions test/sql/test_profile/T/test_load_profile
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
-- name: test_load_profile
CREATE TABLE `t0` (
`v1` int(11) NOT NULL,
`v2` int(11) NOT NULL,
`v3` int(11) NOT NULL
) ENGINE=OLAP
DUPLICATE KEY(`v1`)
DISTRIBUTED BY HASH(`v1`) BUCKETS 10
PROPERTIES (
"replication_num" = "1"
);

SET enable_profile="true";

INSERT INTO `t0` (v1, v2, v3) values
(1, 1, 1),
(1, 1, 2),
(1, 1, 3),
(1, 2, 4),
(1, 2, 5),
(1, 2, 6),
(2, 3, 7),
(2, 3, 8),
(2, 3, 9),
(2, 4, 10),
(2, 4, 11),
(2, 4, 12);

with
profile as (
select unnest as line from (values(1))t(v) join unnest(split(get_query_profile(last_query_id()), "\n") )
), result as (
select * from profile
where REGEXP(line, "- (RowsRead|RowsReturned|RowsFiltered|OpenTime|CloseWaitTime|PrepareDataTime)")
OR REGEXP(line, "- (ConvertChunkTime|ValidateDataTime|SendDataTime|PackChunkTime|SendRpcTime)")
OR REGEXP(line, "- (WaitResponseTime|SerializeChunkTime|CompressTime|RpcClientSideTime|RpcServerSideTime)")
OR REGEXP(line, "- (RpcServerWaitFlushTime|TxnID|IndexNum|ReplicatedStorage|AllocAutoIncrementTime)")
OR REGEXP(line, "- (AutomaticPartition)")
)
select count(*) from result;

0 comments on commit 8f6f6b3

Please sign in to comment.