Skip to content

Commit 42a341b

Browse files
authored
YQ-3600 fixed sessions leak in metadata service (#8312)
1 parent ed35469 commit 42a341b

File tree

4 files changed

+25
-6
lines changed

4 files changed

+25
-6
lines changed

ydb/services/metadata/ds_table/accessor_refresh.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ void TDSAccessorRefresher::OnBootstrap() {
99
}
1010

1111
void TDSAccessorRefresher::OnNewEnrichedSnapshot(NFetcher::ISnapshot::TPtr snapshot) {
12+
FetchingRequestIsRunning = false;
1213
Schedule(Config.GetRefreshPeriod(), new TEvRefresh());
1314
CurrentSnapshot = snapshot;
1415
*CurrentSelection.mutable_result_sets() = std::move(*ProposedProto.mutable_result_sets());
@@ -22,19 +23,24 @@ void TDSAccessorRefresher::OnNewParsedSnapshot(Ydb::Table::ExecuteQueryResult&&
2223
ALS_INFO(NKikimrServices::METADATA_PROVIDER) << "New refresher data: " << ProposedProto.DebugString();
2324
SnapshotConstructor->EnrichSnapshotData(snapshot, InternalController);
2425
} else {
26+
FetchingRequestIsRunning = false;
2527
CurrentSnapshot->SetActuality(GetRequestedActuality());
2628
OnSnapshotRefresh();
2729
Schedule(Config.GetRefreshPeriod(), new TEvRefresh());
2830
}
2931
}
3032

3133
void TDSAccessorRefresher::OnConstructSnapshotError(const TString& errorMessage) {
34+
FetchingRequestIsRunning = false;
3235
TBase::OnConstructSnapshotError(errorMessage);
3336
Schedule(Config.GetRefreshPeriod(), new TEvRefresh());
3437
}
3538

3639
void TDSAccessorRefresher::Handle(TEvRefresh::TPtr& /*ev*/) {
37-
TBase::StartSnapshotsFetching();
40+
if (!FetchingRequestIsRunning) {
41+
FetchingRequestIsRunning = true;
42+
TBase::StartSnapshotsFetching();
43+
}
3844
}
3945

4046
}

ydb/services/metadata/ds_table/accessor_refresh.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ class TDSAccessorRefresher: public TDSAccessorBase {
99
YDB_READONLY_DEF(NFetcher::ISnapshot::TPtr, CurrentSnapshot);
1010
YDB_READONLY_DEF(Ydb::Table::ExecuteQueryResult, CurrentSelection);
1111
Ydb::Table::ExecuteQueryResult ProposedProto;
12+
bool FetchingRequestIsRunning = false;
1213
const TConfig Config;
1314

1415
void Handle(TEvRefresh::TPtr& ev);

ydb/services/metadata/ds_table/accessor_subscribe.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ void TDSAccessorNotifier::OnSnapshotRefresh() {
5252
++it;
5353
}
5454
}
55+
if (!Asked.empty()) {
56+
Sender<TEvRefresh>().SendTo(SelfId());
57+
}
5558
}
5659

5760
void TDSAccessorNotifier::OnBootstrap() {

ydb/services/metadata/manager/alter_impl.h

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,10 @@ class TModificationActorImpl: public NActors::TActorBootstrapped<TModificationAc
120120
InitState();
121121
if (!Patches.size()) {
122122
ExternalController->OnAlteringProblem("no patches");
123-
return TBase::PassAway();
123+
return this->PassAway();
124124
}
125125
if (!BuildRestoreObjectIds()) {
126-
return TBase::PassAway();
126+
return this->PassAway();
127127
}
128128

129129
TBase::Register(new NRequest::TYDBCallbackRequest<NRequest::TDialogCreateSession>(
@@ -146,7 +146,7 @@ class TModificationActorImpl: public NActors::TActorBootstrapped<TModificationAc
146146
Y_ABORT_UNLESS(TransactionId);
147147
std::vector<TObject> objects = std::move(ev->Get()->MutableObjects());
148148
if (!PrepareRestoredObjects(objects)) {
149-
TBase::PassAway();
149+
this->PassAway();
150150
} else {
151151
Manager->PrepareObjectsBeforeModification(std::move(objects), InternalController, Context, TAlterOperationContext(SessionId, TransactionId, RestoreObjectIds));
152152
}
@@ -159,12 +159,12 @@ class TModificationActorImpl: public NActors::TActorBootstrapped<TModificationAc
159159
for (auto&& i : ev->Get()->GetObjects()) {
160160
if (!records.AddRecordNativeValues(i.SerializeToRecord())) {
161161
ExternalController->OnAlteringProblem("unexpected serialization inconsistency");
162-
return TBase::PassAway();
162+
return this->PassAway();
163163
}
164164
}
165165
if (!ProcessPreparedObjects(std::move(records))) {
166166
ExternalController->OnAlteringProblem("cannot process prepared objects");
167-
return TBase::PassAway();
167+
return this->PassAway();
168168
}
169169
}
170170

@@ -183,6 +183,15 @@ class TModificationActorImpl: public NActors::TActorBootstrapped<TModificationAc
183183
ExternalController->OnAlteringProblem("cannot restore objects: " + ev->Get()->GetErrorMessage());
184184
}
185185

186+
void PassAway() override {
187+
if (SessionId) {
188+
NMetadata::NRequest::TDialogDeleteSession::TRequest deleteRequest;
189+
deleteRequest.set_session_id(SessionId);
190+
TBase::Register(new NRequest::TYDBCallbackRequest<NRequest::TDialogDeleteSession>(deleteRequest, UserToken, TBase::SelfId()));
191+
}
192+
193+
TBase::PassAway();
194+
}
186195
};
187196

188197
template <class TObject>

0 commit comments

Comments
 (0)