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];
|
||||
if (OB_FAIL(mutex.lock())) {
|
||||
LOG_WARN("failed to get lock", K(ret));
|
||||
} else if (OB_ENTRY_NOT_EXIST == (ret = node_map_.get(key, table_node))) {
|
||||
LOG_INFO("alloc table node for auto increment key", K(key));
|
||||
if (OB_FAIL(node_map_.alloc_value(table_node))) {
|
||||
LOG_ERROR("failed to alloc table node", K(param), K(ret));
|
||||
} else if (OB_FAIL(table_node->init(param.autoinc_table_part_num_))) {
|
||||
LOG_ERROR("failed to init table node", K(param), K(ret));
|
||||
} else {
|
||||
table_node->prefetch_node_.reset();
|
||||
table_node->autoinc_version_ = param.autoinc_version_;
|
||||
lib::ObMutexGuard guard(map_mutex_);
|
||||
if (OB_FAIL(node_map_.insert_and_get(key, table_node))) {
|
||||
LOG_WARN("failed to create table node", K(param), K(ret));
|
||||
} else {
|
||||
if (OB_ENTRY_NOT_EXIST == (ret = node_map_.get(key, table_node))) {
|
||||
LOG_INFO("alloc table node for auto increment key", K(key));
|
||||
if (OB_FAIL(node_map_.alloc_value(table_node))) {
|
||||
LOG_ERROR("failed to alloc table node", K(param), K(ret));
|
||||
} else if (OB_FAIL(table_node->init(param.autoinc_table_part_num_))) {
|
||||
LOG_ERROR("failed to init table node", K(param), K(ret));
|
||||
} else {
|
||||
table_node->prefetch_node_.reset();
|
||||
table_node->autoinc_version_ = param.autoinc_version_;
|
||||
lib::ObMutexGuard guard(map_mutex_);
|
||||
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) {
|
||||
node_map_.free_value(table_node);
|
||||
table_node = NULL;
|
||||
}
|
||||
mutex.unlock();
|
||||
}
|
||||
mutex.unlock();
|
||||
}
|
||||
} else {
|
||||
if (OB_FAIL(alloc_autoinc_try_lock(table_node->alloc_mutex_))) {
|
||||
LOG_WARN("failed to get lock", K(ret));
|
||||
} else if (OB_UNLIKELY(param.autoinc_version_ != table_node->autoinc_version_)) {
|
||||
LOG_INFO("start reset table node", K(*table_node), K(param));
|
||||
table_node->next_value_ = 0;
|
||||
table_node->local_sync_ = 0;
|
||||
table_node->curr_node_.reset();
|
||||
table_node->prefetch_node_.reset();
|
||||
table_node->prefetching_ = false;
|
||||
table_node->curr_node_state_is_pending_ = true;
|
||||
table_node->autoinc_version_ = param.autoinc_version_;
|
||||
} else {
|
||||
if (OB_UNLIKELY(param.autoinc_version_ != table_node->autoinc_version_)) {
|
||||
LOG_INFO("start reset table node", K(*table_node), K(param));
|
||||
table_node->next_value_ = 0;
|
||||
table_node->local_sync_ = 0;
|
||||
table_node->curr_node_.reset();
|
||||
table_node->prefetch_node_.reset();
|
||||
table_node->prefetching_ = false;
|
||||
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)) {
|
||||
LOG_DEBUG("succ to get table node", K(param), KPC(table_node), K(ret));
|
||||
|
||||
Reference in New Issue
Block a user