Changed FastPath + better diagnostics

This commit is contained in:
akazz 2019-09-05 15:20:10 +03:00
parent 2cda8f1563
commit 54b4db36eb

View File

@ -117,19 +117,28 @@ RWLockImpl::LockHolder RWLockImpl::getLock(RWLockImpl::Type type, const String &
/// Check if the same query is acquiring previously acquired lock /// Check if the same query is acquiring previously acquired lock
if (query_id != RWLockImpl::NO_QUERY) if (query_id != RWLockImpl::NO_QUERY)
{ {
auto it_query = query_id_to_holder.find(query_id); const auto it_query = query_id_to_holder.find(query_id);
if (it_query != query_id_to_holder.end()) if (it_query != query_id_to_holder.end())
{
res = it_query->second.lock(); res = it_query->second.lock();
}
if (res) if (res)
{ {
/// XXX: it means we can't upgrade lock from read to write - with proper waiting! /// XXX: it means we can't upgrade lock from read to write - with proper waiting!
if (type != Read || res->it_group->type != Read) if (type == Write)
throw Exception("Attempt to acquire exclusive lock recursively", ErrorCodes::LOGICAL_ERROR); throw Exception(
else "RWLockImpl::getLock(): Cannot acquire exclusive lock while RWLock is already locked",
ErrorCodes::LOGICAL_ERROR);
if (res->it_group->type == Write)
throw Exception(
"RWLockImpl::getLock(): RWLock is already locked in exclusive mode",
ErrorCodes::LOGICAL_ERROR);
finalize_metrics();
return res; return res;
} }
}
}
/** If the query already has any active read lock and tries to acquire another read lock /** If the query already has any active read lock and tries to acquire another read lock
* but it is not in front of the queue and has to wait, deadlock is possible: * but it is not in front of the queue and has to wait, deadlock is possible: