aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorivanmorozov <ivanmorozov@yandex-team.com>2023-01-22 16:13:17 +0300
committerivanmorozov <ivanmorozov@yandex-team.com>2023-01-22 16:13:17 +0300
commitff6e75892efa3822427135ec727e2bf07b4fb89e (patch)
treec00709bcf639f228f3f46ee86ba75ceb267418bf
parentdea25c5a5a604da1818e9af47acbaf7e7cfab08f (diff)
downloadydb-ff6e75892efa3822427135ec727e2bf07b4fb89e.tar.gz
artefacts cleaning
-rw-r--r--ydb/services/metadata/ds_table/accessor_snapshot_base.cpp40
-rw-r--r--ydb/services/metadata/ds_table/accessor_snapshot_base.h1
-rw-r--r--ydb/services/metadata/ds_table/service.h22
3 files changed, 38 insertions, 25 deletions
diff --git a/ydb/services/metadata/ds_table/accessor_snapshot_base.cpp b/ydb/services/metadata/ds_table/accessor_snapshot_base.cpp
index 409d5f7464..ce1eb1c1f1 100644
--- a/ydb/services/metadata/ds_table/accessor_snapshot_base.cpp
+++ b/ydb/services/metadata/ds_table/accessor_snapshot_base.cpp
@@ -20,12 +20,29 @@ void TDSAccessorBase::Handle(TEvYQLResponse::TPtr& ev) {
auto& currentFullReply = ev->Get()->GetResponse();
Ydb::Table::ExecuteQueryResult qResult;
currentFullReply.operation().result().UnpackTo(&qResult);
- Y_VERIFY((size_t)qResult.result_sets().size() == SnapshotConstructor->GetManagers().size());
- auto parsedSnapshot = SnapshotConstructor->ParseSnapshot(qResult, RequestedActuality);
+
+ auto& managers = SnapshotConstructor->GetManagers();
+ Y_VERIFY(managers.size());
+ Ydb::Table::ExecuteQueryResult qResultFull;
+ ui32 replyIdx = 0;
+ for (auto&& i : managers) {
+ auto it = CurrentExistence.find(i->GetStorageTablePath());
+ Y_VERIFY(it != CurrentExistence.end());
+ Y_VERIFY(it->second);
+ if (it->second == 1) {
+ *qResultFull.add_result_sets() = std::move(qResult.result_sets()[replyIdx]);
+ ++replyIdx;
+ } else {
+ qResultFull.add_result_sets();
+ }
+ }
+ Y_VERIFY((int)replyIdx == qResult.result_sets().size());
+ Y_VERIFY((size_t)qResultFull.result_sets().size() == SnapshotConstructor->GetManagers().size());
+ auto parsedSnapshot = SnapshotConstructor->ParseSnapshot(qResultFull, RequestedActuality);
if (!parsedSnapshot) {
OnIncorrectSnapshotFromYQL("snapshot is null after parsing");
} else {
- OnNewParsedSnapshot(std::move(qResult), parsedSnapshot);
+ OnNewParsedSnapshot(std::move(qResultFull), parsedSnapshot);
}
}
@@ -60,17 +77,16 @@ void TDSAccessorBase::Handle(TTableExistsActor::TEvController::TEvResult::TPtr&
} else {
it->second = -1;
}
- bool hasNonExist = false;
+ bool hasExists = false;
for (auto&& i : ExistenceChecks) {
if (i.second == 0) {
return;
}
- if (i.second == -1) {
- hasNonExist = true;
- continue;
+ if (i.second == 1) {
+ hasExists = true;
}
}
- if (hasNonExist) {
+ if (!hasExists) {
OnNewEnrichedSnapshot(SnapshotConstructor->CreateEmpty(RequestedActuality));
} else {
StartSnapshotsFetchingImpl();
@@ -102,8 +118,14 @@ void TDSAccessorBase::StartSnapshotsFetchingImpl() {
RequestedActuality = TInstant::Now();
auto& managers = SnapshotConstructor->GetManagers();
Y_VERIFY(managers.size());
+ CurrentExistence = ExistenceChecks;
for (auto&& i : managers) {
- sb << "SELECT * FROM `" + EscapeC(i->GetStorageTablePath()) + "`;";
+ auto it = CurrentExistence.find(i->GetStorageTablePath());
+ Y_VERIFY(it != CurrentExistence.end());
+ Y_VERIFY(it->second);
+ if (it->second == 1) {
+ sb << "SELECT * FROM `" + EscapeC(i->GetStorageTablePath()) + "`;" << Endl;
+ }
}
Register(new NRequest::TYQLQuerySessionedActor(sb, NACLib::TSystemUsers::Metadata(), Config, InternalController));
}
diff --git a/ydb/services/metadata/ds_table/accessor_snapshot_base.h b/ydb/services/metadata/ds_table/accessor_snapshot_base.h
index 9f65798920..c5c75df46d 100644
--- a/ydb/services/metadata/ds_table/accessor_snapshot_base.h
+++ b/ydb/services/metadata/ds_table/accessor_snapshot_base.h
@@ -85,6 +85,7 @@ private:
YDB_READONLY(TInstant, RequestedActuality, TInstant::Zero());
const NRequest::TConfig Config;
std::map<TString, i32> ExistenceChecks;
+ std::map<TString, i32> CurrentExistence;
void StartSnapshotsFetchingImpl();
protected:
std::shared_ptr<TRefreshInternalController> InternalController;
diff --git a/ydb/services/metadata/ds_table/service.h b/ydb/services/metadata/ds_table/service.h
index e9577b4bf3..de7ef4f055 100644
--- a/ydb/services/metadata/ds_table/service.h
+++ b/ydb/services/metadata/ds_table/service.h
@@ -35,23 +35,13 @@ private:
void Activate();
template <class TAction>
- void ProcessEventWithFetcher(IEventHandle& ev, NFetcher::ISnapshotsFetcher::TPtr fetcher, TAction action) {
- std::vector<IClassBehaviour::TPtr> needManagers;
- for (auto&& i : fetcher->GetManagers()) {
- if (!RegistrationData->Registered.contains(i->GetTypeId())) {
- needManagers.emplace_back(i);
- }
- }
- if (needManagers.empty() || (needManagers.size() == 1 && needManagers[0]->GetTypeId() == NInitializer::TDBInitialization::GetTypeId())) {
- auto it = Accessors.find(fetcher->GetComponentId());
- if (it == Accessors.end()) {
- THolder<TExternalData> actor = MakeHolder<TExternalData>(Config, fetcher);
- it = Accessors.emplace(fetcher->GetComponentId(), Register(actor.Release())).first;
- }
- action(it->second);
- } else {
- PrepareManagers(needManagers, ev.ReleaseBase(), ev.Sender);
+ void ProcessEventWithFetcher(IEventHandle& /*ev*/, NFetcher::ISnapshotsFetcher::TPtr fetcher, TAction action) {
+ auto it = Accessors.find(fetcher->GetComponentId());
+ if (it == Accessors.end()) {
+ THolder<TExternalData> actor = MakeHolder<TExternalData>(Config, fetcher);
+ it = Accessors.emplace(fetcher->GetComponentId(), Register(actor.Release())).first;
}
+ action(it->second);
}
public: