@@ -281,8 +281,11 @@ namespace NDiscoveryPrivate {
281
281
282
282
class TDiscoveryCache : public TActorBootstrapped <TDiscoveryCache> {
283
283
THashMap<TString, std::shared_ptr<NDiscovery::TCachedMessageData>> CurrentCachedMessages;
284
+ THashMap<TString, std::shared_ptr<NDiscovery::TCachedMessageData>> DirtyCachedMessages;
285
+
284
286
THashMap<TString, std::shared_ptr<NDiscovery::TCachedMessageData>> OldCachedMessages; // when subscriptions are disabled
285
287
THashMap<TString, std::shared_ptr<NDiscovery::TCachedMessageData>> CachedNotAvailable; // for subscriptions
288
+
286
289
THolder<TEvInterconnect::TEvNodeInfo> NameserviceResponse;
287
290
TBridgeInfo::TPtr BridgeInfo;
288
291
@@ -354,7 +357,10 @@ namespace NDiscoveryPrivate {
354
357
auto & currentCachedMessage = CurrentCachedMessages[path];
355
358
Y_ABORT_UNLESS (currentCachedMessage);
356
359
357
- currentCachedMessage->UpdateEntries (std::move (msg->Updates ));
360
+ if (!msg->Updates .empty ()) {
361
+ currentCachedMessage->UpdateEntries (std::move (msg->Updates ));
362
+ DirtyCachedMessages[path] = currentCachedMessage;
363
+ }
358
364
359
365
auto it = Requested.find (path);
360
366
Y_ABORT_UNLESS (it == Requested.end ());
@@ -382,6 +388,8 @@ namespace NDiscoveryPrivate {
382
388
EndpointId.GetOrElse ({}), {}, msg->Status )
383
389
);
384
390
391
+ DirtyCachedMessages.erase (path);
392
+
385
393
if (AppData ()->FeatureFlags .GetEnableSubscriptionsInDiscovery ()) {
386
394
if (msg->Status != TEvStateStorage::TEvBoardInfo::EStatus::Ok) {
387
395
CurrentCachedMessages.erase (path);
@@ -416,10 +424,12 @@ namespace NDiscoveryPrivate {
416
424
Y_ABORT_UNLESS (NameserviceResponse);
417
425
Y_ABORT_UNLESS (!IsBridgeMode (ActorContext ()) || BridgeInfo);
418
426
419
- for (auto & [_, cachedData] : CurrentCachedMessages ) {
427
+ for (auto & [_, cachedData] : DirtyCachedMessages ) {
420
428
cachedData->UpdateCache (NameserviceResponse, BridgeInfo, EndpointId.GetOrElse ({}));
421
429
}
422
430
431
+ DirtyCachedMessages.clear ();
432
+
423
433
Schedule (TDuration::Seconds (1 ), new TEvents::TEvWakeup ());
424
434
}
425
435
0 commit comments