IMPALA-13111: Fix the calculation of fragment ids for impala-gdb.py

The gdb helpers in impala-gdb.py provide functions to look on
the stack for the information added in IMPALA-6416 and get the
fragment/query ids. Right now, it is incorrectly using a signed
integer, which leads to incorrect ids like this:
-3cbda1606b3ade7c:f170c4bd00000000

This changes the logic to AND the integer with an 0xFF* sequence
of the right length. This forces the integer to be unsigned,
producing the right query id.

Testing:
 - Ran this on a minidump and verified the the listed query ids
   were valid (and existed in the profile log)

Change-Id: I59798407e99ee0e9100cac6b4b082cdb85ed43d1
Reviewed-on: http://gerrit.cloudera.org:8080/21472
Reviewed-by: Impala Public Jenkins <impala-public-jenkins@cloudera.com>
Tested-by: Impala Public Jenkins <impala-public-jenkins@cloudera.com>
This commit is contained in:
Joe McDonnell
2024-05-30 12:04:22 -07:00
committed by Impala Public Jenkins
parent 825900fa6c
commit ce8078204e

View File

@@ -49,8 +49,9 @@ def get_fragment_instances():
# No valid thread_debug_info
if not tdi:
break
hi = int(tdi['instance_id_']['hi'])
lo = int(tdi['instance_id_']['lo'])
# ANDing with 0xFFFFFFFFFFFFFFFF forces the value to be unsigned
hi = int(tdi['instance_id_']['hi']) & 0xFFFFFFFFFFFFFFFF
lo = int(tdi['instance_id_']['lo']) & 0xFFFFFFFFFFFFFFFF
fi = "%lx:%lx" % (hi, lo)
if fi != "0:0":
fragment_instances[fi.strip('"')].append(thread.num)
@@ -91,7 +92,12 @@ class FindQueryIds(gdb.Command):
query_ids = set()
for fi in fragment_instances:
qid_hi, qid_low = fi.split(':')
# The ANDing serves two purposes
# - It forces the value to be unsigned
# - For the low value, it masks out the fragment-specific bits to get
# the query id
qid_low = format(int(qid_low, 16) & 0xFFFFFFFFFFFF0000, 'x')
qid_hi = format(int(qid_hi, 16) & 0xFFFFFFFFFFFFFFFF, 'x')
query_ids.add("{}:{}".format(qid_hi, qid_low))
print('\n'.join(query_ids))