Fix auto increment service repeat unlock
This commit is contained in:
@ -736,41 +736,45 @@ int ObAutoincrementService::get_table_node(const AutoincParam ¶m, TableNode
|
|||||||
lib::ObMutex &mutex = init_node_mutex_[table_id % INIT_NODE_MUTEX_NUM];
|
lib::ObMutex &mutex = init_node_mutex_[table_id % INIT_NODE_MUTEX_NUM];
|
||||||
if (OB_FAIL(mutex.lock())) {
|
if (OB_FAIL(mutex.lock())) {
|
||||||
LOG_WARN("failed to get lock", K(ret));
|
LOG_WARN("failed to get lock", K(ret));
|
||||||
} else if (OB_ENTRY_NOT_EXIST == (ret = node_map_.get(key, table_node))) {
|
} else {
|
||||||
LOG_INFO("alloc table node for auto increment key", K(key));
|
if (OB_ENTRY_NOT_EXIST == (ret = node_map_.get(key, table_node))) {
|
||||||
if (OB_FAIL(node_map_.alloc_value(table_node))) {
|
LOG_INFO("alloc table node for auto increment key", K(key));
|
||||||
LOG_ERROR("failed to alloc table node", K(param), K(ret));
|
if (OB_FAIL(node_map_.alloc_value(table_node))) {
|
||||||
} else if (OB_FAIL(table_node->init(param.autoinc_table_part_num_))) {
|
LOG_ERROR("failed to alloc table node", K(param), K(ret));
|
||||||
LOG_ERROR("failed to init table node", K(param), K(ret));
|
} else if (OB_FAIL(table_node->init(param.autoinc_table_part_num_))) {
|
||||||
} else {
|
LOG_ERROR("failed to init table node", K(param), K(ret));
|
||||||
table_node->prefetch_node_.reset();
|
} else {
|
||||||
table_node->autoinc_version_ = param.autoinc_version_;
|
table_node->prefetch_node_.reset();
|
||||||
lib::ObMutexGuard guard(map_mutex_);
|
table_node->autoinc_version_ = param.autoinc_version_;
|
||||||
if (OB_FAIL(node_map_.insert_and_get(key, table_node))) {
|
lib::ObMutexGuard guard(map_mutex_);
|
||||||
LOG_WARN("failed to create table node", K(param), K(ret));
|
if (OB_FAIL(node_map_.insert_and_get(key, table_node))) {
|
||||||
|
LOG_WARN("failed to create table node", K(param), K(ret));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (OB_FAIL(ret) && table_node != nullptr) {
|
||||||
|
node_map_.free_value(table_node);
|
||||||
|
table_node = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (OB_FAIL(ret) && table_node != nullptr) {
|
mutex.unlock();
|
||||||
node_map_.free_value(table_node);
|
|
||||||
table_node = NULL;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
mutex.unlock();
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (OB_FAIL(alloc_autoinc_try_lock(table_node->alloc_mutex_))) {
|
if (OB_FAIL(alloc_autoinc_try_lock(table_node->alloc_mutex_))) {
|
||||||
LOG_WARN("failed to get lock", K(ret));
|
LOG_WARN("failed to get lock", K(ret));
|
||||||
} else if (OB_UNLIKELY(param.autoinc_version_ != table_node->autoinc_version_)) {
|
} else {
|
||||||
LOG_INFO("start reset table node", K(*table_node), K(param));
|
if (OB_UNLIKELY(param.autoinc_version_ != table_node->autoinc_version_)) {
|
||||||
table_node->next_value_ = 0;
|
LOG_INFO("start reset table node", K(*table_node), K(param));
|
||||||
table_node->local_sync_ = 0;
|
table_node->next_value_ = 0;
|
||||||
table_node->curr_node_.reset();
|
table_node->local_sync_ = 0;
|
||||||
table_node->prefetch_node_.reset();
|
table_node->curr_node_.reset();
|
||||||
table_node->prefetching_ = false;
|
table_node->prefetch_node_.reset();
|
||||||
table_node->curr_node_state_is_pending_ = true;
|
table_node->prefetching_ = false;
|
||||||
table_node->autoinc_version_ = param.autoinc_version_;
|
table_node->curr_node_state_is_pending_ = true;
|
||||||
|
table_node->autoinc_version_ = param.autoinc_version_;
|
||||||
|
}
|
||||||
|
table_node->alloc_mutex_.unlock();
|
||||||
}
|
}
|
||||||
table_node->alloc_mutex_.unlock();
|
|
||||||
}
|
}
|
||||||
if (OB_SUCC(ret)) {
|
if (OB_SUCC(ret)) {
|
||||||
LOG_DEBUG("succ to get table node", K(param), KPC(table_node), K(ret));
|
LOG_DEBUG("succ to get table node", K(param), KPC(table_node), K(ret));
|
||||||
|
|||||||
Reference in New Issue
Block a user