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,18 +117,27 @@ 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)
{
/// XXX: it means we can't upgrade lock from read to write - with proper waiting!
if (type == Write)
throw Exception(
"RWLockImpl::getLock(): Cannot acquire exclusive lock while RWLock is already locked",
ErrorCodes::LOGICAL_ERROR);
if (res) if (res->it_group->type == Write)
{ throw Exception(
/// XXX: it means we can't upgrade lock from read to write - with proper waiting! "RWLockImpl::getLock(): RWLock is already locked in exclusive mode",
if (type != Read || res->it_group->type != Read) ErrorCodes::LOGICAL_ERROR);
throw Exception("Attempt to acquire exclusive lock recursively", ErrorCodes::LOGICAL_ERROR);
else 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