Skip to content

Commit 257fa0c

Browse files
Lars VolkerImpala Public Jenkins
authored andcommitted
IMPALA-8209: Include fragment instance ID in memz/ breakdown
The change for IMPALA-7694 had accidentally removed the fragment instance ID from the memz/ breakdown. This change puts it back and adds a test to make sure it's there. This change also pads query IDs with zeros when printing them in the backend. Change-Id: I73bf06bf95c88186b16fd03243de9bac946c5cc8 Reviewed-on: http://gerrit.cloudera.org:8080/12524 Reviewed-by: Impala Public Jenkins <[email protected]> Tested-by: Impala Public Jenkins <[email protected]>
1 parent 113b2eb commit 257fa0c

File tree

4 files changed

+19
-3
lines changed

4 files changed

+19
-3
lines changed

be/src/runtime/runtime-state.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@ RuntimeState::RuntimeState(QueryState* query_state, const TPlanFragmentCtx& frag
7373
utc_timestamp_(new TimestampValue(
7474
TimestampValue::Parse(query_state->query_ctx().utc_timestamp_string))),
7575
local_time_zone_(&TimezoneDatabase::GetUtcTimezone()),
76-
profile_(RuntimeProfile::Create(obj_pool(), "<fragment instance>")),
76+
profile_(RuntimeProfile::Create(
77+
obj_pool(), "Fragment " + PrintId(instance_ctx.fragment_instance_id))),
7778
instance_buffer_reservation_(new ReservationTracker) {
7879
Init();
7980
}

be/src/util/debug-util-test.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ TEST(DebugUtil, UniqueID) {
3434
std::string str("feedbeeff00d7777:2020202020202020");
3535
EXPECT_EQ(str, PrintId(unique_id));
3636
unique_id.lo = 0x20ULL;
37-
EXPECT_EQ("feedbeeff00d7777:20", PrintId(unique_id));
37+
EXPECT_EQ("feedbeeff00d7777:0000000000000020", PrintId(unique_id));
3838
}
3939

4040
string RecursionStack(int level) {

be/src/util/debug-util.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,8 @@ PRINT_THRIFT_ENUM_IMPL(TUnit)
8888

8989
string PrintId(const TUniqueId& id, const string& separator) {
9090
stringstream out;
91-
out << hex << id.hi << separator << id.lo;
91+
// Outputting the separator string resets the stream width.
92+
out << hex << setfill('0') << setw(16) << id.hi << separator << setw(16) << id.lo;
9293
return out.str();
9394
}
9495

tests/webserver/test_web_pages.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
from tests.common.impala_test_suite import ImpalaTestSuite
2323
import json
2424
import pytest
25+
import re
2526
import requests
2627

2728

@@ -40,6 +41,7 @@ class TestWebPage(ImpalaTestSuite):
4041
QUERY_FINSTANCES_URL = "http://localhost:{0}/query_finstances"
4142
RPCZ_URL = "http://localhost:{0}/rpcz"
4243
THREAD_GROUP_URL = "http://localhost:{0}/thread-group"
44+
MEMZ_URL = "http://localhost:{0}/memz"
4345
METRICS_URL = "http://localhost:{0}/metrics"
4446
JMX_URL = "http://localhost:{0}/jmx"
4547
ADMISSION_URL = "http://localhost:{0}/admission"
@@ -111,6 +113,18 @@ def test_memz(self):
111113
page = requests.get("http://localhost:25020/memz")
112114
assert page.status_code == requests.codes.ok
113115

116+
def test_memz_shows_fragment_instance_id(self):
117+
"""Tests that the memory breakdown on memz shows fragment instance IDs."""
118+
query = "select count(*) from functional_parquet.alltypes where bool_col = sleep(100)"
119+
query_handle = self.client.execute_async(query)
120+
try:
121+
self.wait_for_state(query_handle, self.client.QUERY_STATES['RUNNING'], 1000)
122+
memz_breakdown = self.get_debug_page(self.MEMZ_URL)['detailed']
123+
finstance_re = re.compile("Fragment [0-9a-f]{16}:[0-9a-f]{16}")
124+
assert finstance_re.search(memz_breakdown), memz_breakdown
125+
finally:
126+
self.client.close_query(query_handle)
127+
114128
def test_query_profile_encoded_unknown_query_id(self):
115129
"""Test that /query_profile_encoded error message starts with the expected line in
116130
case of missing query and does not contain any leading whitespace.

0 commit comments

Comments
 (0)