This is an automated email from the ASF dual-hosted git repository. asherman pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/impala.git
commit 0206d2ada03d98c91be65eb6507ed9cbfa108552 Author: Kurt Deschler <[email protected]> AuthorDate: Thu Mar 30 09:16:55 2023 -0500 IMPALA-12033: Impalad crashes when --dump_exec_request_path is used This patch fixes 2 bugs in DumpTExecReq that were leading to crashes and printing issues when the --dump_exec_request_path flag was set. It also improves dumping of descriptor tables by printing the deserialized contents or else hex data if deserialization fails. Testing: Manually verified dump file contents. Tested hex printing by forcing codepath. Change-Id: I217f360a7df4fc1d3c0d0ae8af8d738a56356935 Reviewed-on: http://gerrit.cloudera.org:8080/19664 Reviewed-by: Impala Public Jenkins <[email protected]> Tested-by: Impala Public Jenkins <[email protected]> --- be/src/runtime/descriptors.cc | 19 +++++++++++++++++++ be/src/runtime/descriptors.h | 10 +++++----- be/src/service/impala-server.cc | 7 ++++--- common/thrift/Descriptors.thrift | 2 +- 4 files changed, 29 insertions(+), 9 deletions(-) diff --git a/be/src/runtime/descriptors.cc b/be/src/runtime/descriptors.cc index 47234e168..df3b71790 100644 --- a/be/src/runtime/descriptors.cc +++ b/be/src/runtime/descriptors.cc @@ -819,4 +819,23 @@ string DescriptorTbl::DebugString() const { return out.str(); } +std::ostream& operator<<(std::ostream& out, + const TDescriptorTableSerialized& serial_tbl) { + out << "TDescriptorTableSerialized("; + TDescriptorTable desc_tbl; + if (DescriptorTbl::DeserializeThrift(serial_tbl, &desc_tbl).ok()) { + out << desc_tbl; + } else { + const uint8_t* p = + reinterpret_cast<const uint8_t*>(serial_tbl.thrift_desc_tbl.data()); + const uint8_t* const end = p + serial_tbl.thrift_desc_tbl.length(); + while (p != end) { + out << ios::hex << (int)*p++; + } + } + out << ")"; + return out; } + +} + diff --git a/be/src/runtime/descriptors.h b/be/src/runtime/descriptors.h index be50ccfaa..27565190f 100644 --- a/be/src/runtime/descriptors.h +++ b/be/src/runtime/descriptors.h @@ -573,6 +573,11 @@ class DescriptorTbl { std::string DebugString() const; + /// Converts a TDescriptorTableSerialized to a TDescriptorTable. Returns + /// an error if deserialization fails. + static Status DeserializeThrift(const TDescriptorTableSerialized& serial_tbl, + TDescriptorTable* desc_tbl) WARN_UNUSED_RESULT; + private: // The friend classes use CreateInternal(). friend class DescriptorTblBuilder; @@ -590,11 +595,6 @@ class DescriptorTbl { static Status CreatePartKeyExprs( const HdfsTableDescriptor& hdfs_tbl, ObjectPool* pool) WARN_UNUSED_RESULT; - /// Converts a TDescriptorTableSerialized to a TDescriptorTable. Returns - /// an error if deserialization fails. - static Status DeserializeThrift(const TDescriptorTableSerialized& serial_tbl, - TDescriptorTable* desc_tbl) WARN_UNUSED_RESULT; - /// Creates a TableDescriptor (allocated in 'pool', returned via 'desc') /// corresponding to tdesc. Returns error status on failure. static Status CreateTblDescriptorInternal(const TTableDescriptor& tdesc, diff --git a/be/src/service/impala-server.cc b/be/src/service/impala-server.cc index 4d6f64840..c1a92caf9 100644 --- a/be/src/service/impala-server.cc +++ b/be/src/service/impala-server.cc @@ -1172,12 +1172,13 @@ void DumpTExecReq(const TExecRequest& exec_request, const char* dump_type, if (FLAGS_dump_exec_request_path.empty()) return; int depth = 0; std::stringstream tmpstr; - string fn(Substitute("$1/TExecRequest-$2.$3", FLAGS_dump_exec_request_path, + string fn(Substitute("$0/TExecRequest-$1.$2", FLAGS_dump_exec_request_path, dump_type, PrintId(query_id, "-"))); std::ofstream ofs(fn); tmpstr << exec_request; - const int len = tmpstr.str().length(); - const char *p = tmpstr.str().c_str(); + std::string s = tmpstr.str(); + const char *p = s.c_str(); + const int len = s.length(); for (int i = 0; i < len; ++i) { const char ch = p[i]; ofs << ch; diff --git a/common/thrift/Descriptors.thrift b/common/thrift/Descriptors.thrift index 83bf50d15..d44aab551 100644 --- a/common/thrift/Descriptors.thrift +++ b/common/thrift/Descriptors.thrift @@ -112,4 +112,4 @@ struct TDescriptorTable { struct TDescriptorTableSerialized { // TDescriptorTable serialized 1: required binary thrift_desc_tbl -} +} (cpp.customostream)
