Skip to content

Commit

Permalink
IMPALA-8209: Include fragment instance ID in memz/ breakdown
Browse files Browse the repository at this point in the history
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 <impala-public-jenkins@cloudera.com>
Tested-by: Impala Public Jenkins <impala-public-jenkins@cloudera.com>
  • Loading branch information
Lars Volker authored and Impala Public Jenkins committed Feb 21, 2019
1 parent 113b2eb commit 257fa0c
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 3 deletions.
3 changes: 2 additions & 1 deletion be/src/runtime/runtime-state.cc
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ RuntimeState::RuntimeState(QueryState* query_state, const TPlanFragmentCtx& frag
utc_timestamp_(new TimestampValue(
TimestampValue::Parse(query_state->query_ctx().utc_timestamp_string))),
local_time_zone_(&TimezoneDatabase::GetUtcTimezone()),
profile_(RuntimeProfile::Create(obj_pool(), "<fragment instance>")),
profile_(RuntimeProfile::Create(
obj_pool(), "Fragment " + PrintId(instance_ctx.fragment_instance_id))),
instance_buffer_reservation_(new ReservationTracker) {
Init();
}
Expand Down
2 changes: 1 addition & 1 deletion be/src/util/debug-util-test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ TEST(DebugUtil, UniqueID) {
std::string str("feedbeeff00d7777:2020202020202020");
EXPECT_EQ(str, PrintId(unique_id));
unique_id.lo = 0x20ULL;
EXPECT_EQ("feedbeeff00d7777:20", PrintId(unique_id));
EXPECT_EQ("feedbeeff00d7777:0000000000000020", PrintId(unique_id));
}

string RecursionStack(int level) {
Expand Down
3 changes: 2 additions & 1 deletion be/src/util/debug-util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ PRINT_THRIFT_ENUM_IMPL(TUnit)

string PrintId(const TUniqueId& id, const string& separator) {
stringstream out;
out << hex << id.hi << separator << id.lo;
// Outputting the separator string resets the stream width.
out << hex << setfill('0') << setw(16) << id.hi << separator << setw(16) << id.lo;
return out.str();
}

Expand Down
14 changes: 14 additions & 0 deletions tests/webserver/test_web_pages.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
from tests.common.impala_test_suite import ImpalaTestSuite
import json
import pytest
import re
import requests


Expand All @@ -40,6 +41,7 @@ class TestWebPage(ImpalaTestSuite):
QUERY_FINSTANCES_URL = "http://localhost:{0}/query_finstances"
RPCZ_URL = "http://localhost:{0}/rpcz"
THREAD_GROUP_URL = "http://localhost:{0}/thread-group"
MEMZ_URL = "http://localhost:{0}/memz"
METRICS_URL = "http://localhost:{0}/metrics"
JMX_URL = "http://localhost:{0}/jmx"
ADMISSION_URL = "http://localhost:{0}/admission"
Expand Down Expand Up @@ -111,6 +113,18 @@ def test_memz(self):
page = requests.get("http://localhost:25020/memz")
assert page.status_code == requests.codes.ok

def test_memz_shows_fragment_instance_id(self):
"""Tests that the memory breakdown on memz shows fragment instance IDs."""
query = "select count(*) from functional_parquet.alltypes where bool_col = sleep(100)"
query_handle = self.client.execute_async(query)
try:
self.wait_for_state(query_handle, self.client.QUERY_STATES['RUNNING'], 1000)
memz_breakdown = self.get_debug_page(self.MEMZ_URL)['detailed']
finstance_re = re.compile("Fragment [0-9a-f]{16}:[0-9a-f]{16}")
assert finstance_re.search(memz_breakdown), memz_breakdown
finally:
self.client.close_query(query_handle)

def test_query_profile_encoded_unknown_query_id(self):
"""Test that /query_profile_encoded error message starts with the expected line in
case of missing query and does not contain any leading whitespace.
Expand Down

0 comments on commit 257fa0c

Please sign in to comment.