Zoltán Borók-Nagy created IMPALA-15848:
------------------------------------------
Summary: KrpcDataStreamRecvr::SenderQueue::AddBatch() unlocks
lock_ twice
Key: IMPALA-15848
URL: https://issues.apache.org/jira/browse/IMPALA-15848
Project: IMPALA
Issue Type: Bug
Components: Backend
Affects Versions: Impala 5.0.0
Reporter: Zoltán Borók-Nagy
Assignee: Zoltán Borók-Nagy
An impalad (debug build of master) crashed in
test_scanners.py::TestScannersAllTableFormatsWithLimit::test_limit with two
DCHECKs on the same exchange receiver at the same time:
{noformat}
F20261119 15:38:58.044704 172 krpc-data-stream-recvr.cc:584] Check failed:
!status.ok() || !batch_queue_.empty()
F20261119 15:38:58.043568 264117 mem-tracker.cc:139] Check failed:
consumption_->current_value() == 0 (2620 vs. 0) KrpcDeferredRpcs
@ 0x4f55ed3 impala::MemTracker::Close()
@ 0x4f3b1af impala::KrpcDataStreamRecvr::Close()
@ 0x4298af0 impala::ExchangeNode::Close()
@ 0x4f2408f impala::FragmentInstanceState::ExecInternal()
{noformat}
IMPALA-13475 added a {{lock_.unlock()}} call to the is-cancelled branch of
{{SenderQueue::AddBatch()}}, but a {{unique_lock}} still owns the lock there
and unlocks it again on return. {{base::SpinLock::Unlock()}} does not check the
owner, so the second unlock releases the lock while another thread holds it. In
this crash {{Close()}} emptied the batch queue and closed the deferred RPC
MemTracker while a deserialization thread was still between enqueueing its
batch and releasing the RPC's memory.
The branch runs whenever a TransmitData RPC reaches a receiver that was just
cancelled, e.g. when a LIMIT closes the exchange early. Release builds lose the
same mutual exclusion, so the receiver state can be corrupted there too.
The fix is to call {{l.unlock()}} instead, like {{TakeOverEarlySender()}}
already does.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)