!1763 设置分布式数据库表时若不支持自动同步,则将cloudTables_中存在设置的表删除

Merge pull request !1763 from shenpeixing/master
This commit is contained in:
openharmony_ci 2024-09-26 10:58:12 +00:00 committed by Gitee
commit 04bdb1b020
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F

View File

@ -1856,21 +1856,24 @@ int RdbStoreImpl::SetDistributedTables(const std::vector<std::string> &tables, i
LOG_ERROR("Fail to set distributed tables, error=%{public}d", errorCode);
return errorCode;
}
if (type == DistributedRdb::DISTRIBUTED_CLOUD) {
auto conn = connectionPool_->AcquireConnection(false);
if (conn != nullptr) {
auto strategy = conn->GenerateExchangeStrategy(slaveStatus_);
if (strategy == ExchangeStrategy::BACKUP) {
(void)conn->Backup({}, {}, false, slaveStatus_);
}
}
}
if (type != DistributedRdb::DISTRIBUTED_CLOUD || !distributedConfig.autoSync) {
if (type != DistributedRdb::DISTRIBUTED_CLOUD) {
return E_OK;
}
auto conn = connectionPool_->AcquireConnection(false);
if (conn != nullptr) {
auto strategy = conn->GenerateExchangeStrategy(slaveStatus_);
if (strategy == ExchangeStrategy::BACKUP) {
(void)conn->Backup({}, {}, false, slaveStatus_);
}
}
{
std::unique_lock<decltype(rwMutex_)> lock(rwMutex_);
cloudTables_.insert(tables.begin(), tables.end());
if (distributedConfig.autoSync) {
cloudTables_.insert(tables.begin(), tables.end());
} else {
std::for_each(tables.begin(), tables.end(), [this](const auto &table) { cloudTables_.erase(table); });
return E_OK;
}
}
auto isRebuilt = RebuiltType::NONE;
GetRebuilt(isRebuilt);