If you'd like to contribute a patch to Impala, but aren't sure what
you want to work on, you can look at Impala's newbie issues:
https://issues.apache.org/jira/issues/?filter=12341668. You can find
detailed instructions on submitting patches at
https://cwiki.apache.org/confluence/display/IMPALA/Contributing+to+Impala.
This is a walkthrough of a ticket a new contributor could take on,
with hopefully enough detail to get you going but not so much to take
away the fun.

How can we solve https://issues.apache.org/jira/browse/IMPALA-6296,
"DCheck in CodegenSymbolEmitter when --asm_module_dir is set on debug build
"?
First, make sure you have your development environment set up. Let's
see if we can reproduce the issue.

Create a directory for the codegen modules then start impala-server
$ mkdir codegen-modules
$ start-impala-cluster.py --impalad_args="--opt_module_dir=codegen-modules
--unopt_module_dir=codegen-modules --asm_module_dir=codegen-modules"

Now run a query through Impala. I chose this query because it uses Impala's
runtime code generation ("codegen") to improve performance
$ bin/impala-shell.sh -q "select count(*) from tpch.lineitem"

After a few seconds, you should see an error from Impala crashing:
Error communicating with impalad: TSocket read 0 bytes
Could not execute command: select count(*) from tpch.lineitem

Attempting to run any further queries will fail because of the crashed
Impala daemons:
$ impala-shell.sh -q "select count(*) from tpch.lineitem";
Starting Impala Shell without Kerberos authentication
Error connecting: TTransportException, Could not connect to localhost:21000
Not connected to Impala, could not execute queries.

If you look at logs/cluster/impalad.ERROR you will see a message explaining
the crash - we hit a DCHECK (a.k.a. an assertion):

F1212 17:10:07.642722  9138 codegen-symbol-emitter.cc:90] Check failed:
perf_map_.find(obj.getData().data()) != perf_map_.end()
*** Check failure stack trace: ***
    @          0x3be16ed  google::LogMessage::Fail()
    @          0x3be2f92  google::LogMessage::SendToLog()
    @          0x3be10c7  google::LogMessage::Flush()
    @          0x3be468e  google::LogMessageFatal::~LogMessageFatal()
    @          0x1b354f1
impala::CodegenSymbolEmitter::NotifyFreeingObject()
    @          0x375b791  llvm::MCJIT::NotifyFreeingObject()
    @          0x375b811  llvm::MCJIT::~MCJIT()
    @          0x375bfc9  llvm::MCJIT::~MCJIT()
    @          0x1b265ba  std::default_delete<>::operator()()
    @          0x1b23e21  std::unique_ptr<>::reset()
    @          0x1b11198  impala::LlvmCodeGen::Close()
    @          0x182194d  impala::RuntimeState::ReleaseResources()
    @          0x1893a35  impala::FragmentInstanceState::Close()
    @          0x1890d58  impala::FragmentInstanceState::Exec()
    @          0x1879afa  impala::QueryState::ExecFInstance()
    @          0x18783bc
_ZZN6impala10QueryState15StartFInstancesEvENKUlvE_clEv
    @          0x187a739
_ZN5boost6detail8function26void_function_obj_invoker0IZN6impala10QueryState15StartFInstancesEvEUlvE_vE6invokeERNS1_15function_bufferE
    @          0x17c7200  boost::function0<>::operator()()
    @          0x1abdf8b  impala::Thread::SuperviseThread()
    @          0x1ac6b16  boost::_bi::list4<>::operator()<>()
    @          0x1ac6a59  boost::_bi::bind_t<>::operator()()
    @          0x1ac6a1c  boost::detail::thread_data<>::run()
    @          0x2d6b08a  thread_proxy
    @     0x7fcb5ff146ba  start_thread
    @     0x7fcb5fc4a3dd  clone

It looks like something is wrong with the code - 'perf_map_' doesn't have
anything in it. If we look a few lines above, it looks like 'perf_map_' is
only filled in if 'emit_perf_map_' is true.

  if (emit_perf_map_) {
    lock_guard<SpinLock> perf_map_lock(perf_map_lock_);
    DCHECK(perf_map_.find(obj.getData().data()) == perf_map_.end());
    perf_map_[obj.getData().data()] = std::move(perf_map_entries);
    WritePerfMapLocked();
  }

Maybe we should also be checking 'emit_perf_map_' before the DCHECK?

After you have fixed this bug, you should be able to run the query without
Impala crashing and you should be able to inspect the assembly generated by
Impala in codegen-modules/*.asm

Have fun, and don't be afraid to ask [email protected] is you have
any questions!

Reply via email to