Resolved the issue of deadlocks caused by repeatedly acquiring write locks when deleting all interm results of a tenant

This commit is contained in:
obdev
2024-02-08 16:20:22 +00:00
committed by ob-robot
parent 74ab463ae4
commit 3a43b5f75d

View File

@ -389,21 +389,21 @@ int ObDTLIntermResultManager::erase_tenant_interm_result_info()
int ret = OB_SUCCESS; int ret = OB_SUCCESS;
MAP::bucket_iterator bucket_it = map_.bucket_begin(); MAP::bucket_iterator bucket_it = map_.bucket_begin();
while (bucket_it != map_.bucket_end()) { while (bucket_it != map_.bucket_end()) {
MAP::hashtable::bucket_lock_cond blc(*bucket_it); while (true) {
MAP::hashtable::writelocker locker(blc.lock()); ObDTLIntermResultKey key;
MAP::hashtable::hashbucket::const_iterator node_it = bucket_it->node_begin(); {
while (node_it != bucket_it->node_end()) { MAP::hashtable::bucket_lock_cond blc(*bucket_it);
int tmp_ret = OB_SUCCESS; MAP::hashtable::readlocker locker(blc.lock());
const ObDTLIntermResultKey &key = node_it->first; MAP::hashtable::hashbucket::const_iterator node_it = bucket_it->node_begin();
node_it++; if (node_it == bucket_it->node_end()) {
if (OB_SUCCESS != (tmp_ret = erase_interm_result_info(key))) { break;
if (OB_HASH_NOT_EXIST != tmp_ret) { } else {
LOG_WARN("fail to erase result info", K(key), K(tmp_ret)); key = node_it->first;
ret = tmp_ret;
} }
} }
erase_interm_result_info(key);
} }
bucket_it++; ++bucket_it;
} }
if (OB_SUCC(ret)) { if (OB_SUCC(ret)) {
LOG_INFO("erase_tenant_interm_result_info", K(MTL_ID()), K(map_.size())); LOG_INFO("erase_tenant_interm_result_info", K(MTL_ID()), K(map_.size()));