Skip to content

Commit 1731881

Browse files
fix: sdk get all dbs (#3742)
1 parent b8318b8 commit 1731881

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/sdk/db_sdk.cc

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -430,16 +430,19 @@ bool ClusterSDK::BuildCatalog() {
430430
return false;
431431
}
432432
} else {
433-
DLOG(INFO) << "no procedures in db";
433+
LOG(INFO) << "no procedures in db";
434434
}
435+
// The empty database can't be find if we only get table datas, but database no notify, so we get alldbs from
436+
// nameserver in GetAllDbs()
435437
return UpdateCatalog(table_datas, sp_datas);
436438
}
437439

438440
std::vector<std::string> DBSDK::GetAllDbs() {
439-
std::lock_guard<::openmldb::base::SpinMutex> lock(mu_);
440441
std::vector<std::string> all_dbs;
441-
for (auto db_name_iter = table_to_tablets_.begin(); db_name_iter != table_to_tablets_.end(); db_name_iter++) {
442-
all_dbs.push_back(db_name_iter->first);
442+
std::string st;
443+
if (!GetNsClient()->ShowDatabase(&all_dbs, st)) {
444+
LOG(WARNING) << "show db from ns failed, msg: " << st;
445+
return {};
443446
}
444447
return all_dbs;
445448
}

0 commit comments

Comments
 (0)