Skip to content

Commit a856194

Browse files
authored
Use StateStorage proxy stub to prevent incorrect replies while initially configuring (#4993)
1 parent 359f5cb commit a856194

File tree

3 files changed

+32
-29
lines changed

3 files changed

+32
-29
lines changed

ydb/core/base/statestorage_proxy.cpp

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1007,18 +1007,8 @@ class TStateStorageProxy : public TActor<TStateStorageProxy> {
10071007
};
10081008

10091009
class TStateStorageProxyStub : public TActor<TStateStorageProxyStub> {
1010+
std::deque<std::unique_ptr<IEventHandle>> PendingQ;
10101011

1011-
void Handle(TEvStateStorage::TEvLookup::TPtr &ev) {
1012-
BLOG_D("ProxyStub::Handle ev: " << ev->Get()->ToString());
1013-
const TEvStateStorage::TEvLookup *msg = ev->Get();
1014-
const ui64 tabletId = msg->TabletID;
1015-
const ui64 cookie = msg->Cookie;
1016-
1017-
Send(ev->Sender, new TEvStateStorage::TEvInfo(
1018-
NKikimrProto::ERROR,
1019-
tabletId, cookie, TActorId(), TActorId(), 0, 0, false, 0,
1020-
nullptr, 0, TMap<TActorId, TActorId>()));
1021-
}
10221012
public:
10231013
static constexpr NKikimrServices::TActivity::EType ActorActivityType() {
10241014
return NKikimrServices::TActivity::SS_PROXY_STUB;
@@ -1028,15 +1018,14 @@ class TStateStorageProxyStub : public TActor<TStateStorageProxyStub> {
10281018
: TActor(&TThis::StateFunc)
10291019
{}
10301020

1031-
STATEFN(StateFunc) {
1032-
switch (ev->GetTypeRewrite()) {
1033-
hFunc(TEvStateStorage::TEvLookup, Handle);
1034-
default:
1035-
BLOG_W("ProxyStub::StateFunc unexpected event type# "
1036-
<< ev->GetTypeRewrite()
1037-
<< " event: "
1038-
<< ev->ToString());
1039-
break;
1021+
STFUNC(StateFunc) {
1022+
if (ev->GetTypeRewrite() == TEvents::TSystem::Poison) {
1023+
for (auto& q : PendingQ) {
1024+
TActivationContext::Send(q->Forward(ev->Sender));
1025+
}
1026+
PassAway();
1027+
} else {
1028+
PendingQ.emplace_back(ev.Release());
10401029
}
10411030
}
10421031
};

ydb/core/blobstorage/nodewarden/distconf.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include "distconf.h"
22
#include "node_warden_impl.h"
3+
#include <ydb/core/mind/dynamic_nameserver.h>
34

45
namespace NKikimr::NStorage {
56

@@ -16,8 +17,13 @@ namespace NKikimr::NStorage {
1617
void TDistributedConfigKeeper::Bootstrap() {
1718
STLOG(PRI_DEBUG, BS_NODE, NWDC00, "Bootstrap");
1819

19-
// TODO: maybe extract list of nodes from the initial storage config?
20-
Send(GetNameserviceActorId(), new TEvInterconnect::TEvListNodes(true));
20+
// report initial node listing
21+
auto ns = NNodeBroker::BuildNameserverTable(Cfg->NameserviceConfig);
22+
auto ev = std::make_unique<TEvInterconnect::TEvNodesInfo>();
23+
for (const auto& [nodeId, item] : ns->StaticNodeTable) {
24+
ev->Nodes.emplace_back(nodeId, item.Address, item.Host, item.ResolveHost, item.Port, item.Location);
25+
}
26+
Send(SelfId(), ev.release());
2127

2228
// generate initial drive set and query stored configuration
2329
EnumerateConfigDrives(InitialConfig, SelfId().NodeId(), [&](const auto& /*node*/, const auto& drive) {

ydb/core/blobstorage/nodewarden/node_warden_resource.cpp

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -166,13 +166,8 @@ void TNodeWarden::ApplyStateStorageConfig(const NKikimrBlobStorage::TStorageConf
166166
const bool changedStateStorage = !StateStorageProxyConfigured || changed(*StateStorageInfo, *stateStorageInfo);
167167
const bool changedBoard = !StateStorageProxyConfigured || changed(*BoardInfo, *boardInfo);
168168
const bool changedSchemeBoard = !StateStorageProxyConfigured || changed(*SchemeBoardInfo, *schemeBoardInfo);
169-
if (changedStateStorage || changedBoard || changedSchemeBoard) { // reconfigure proxy
170-
STLOG(PRI_INFO, BS_NODE, NW50, "updating state storage proxy configuration");
171-
Send(MakeStateStorageProxyID(), new TEvStateStorage::TEvUpdateGroupConfig(stateStorageInfo, boardInfo,
172-
schemeBoardInfo));
173-
StateStorageProxyConfigured = true;
174-
} else { // no changes
175-
return;
169+
if (!changedStateStorage && !changedBoard && !changedSchemeBoard) {
170+
return; // no changes
176171
}
177172

178173
// start new replicas if needed
@@ -225,6 +220,19 @@ void TNodeWarden::ApplyStateStorageConfig(const NKikimrBlobStorage::TStorageConf
225220
const TActorId actorId = as->RegisterLocalService(actorId, TActorId());
226221
TActivationContext::Send(new IEventHandle(TEvents::TSystem::Poison, 0, actorId, SelfId(), nullptr, 0));
227222
}
223+
224+
// reconfigure proxy
225+
STLOG(PRI_INFO, BS_NODE, NW50, "updating state storage proxy configuration");
226+
if (StateStorageProxyConfigured) {
227+
Send(MakeStateStorageProxyID(), new TEvStateStorage::TEvUpdateGroupConfig(StateStorageInfo, BoardInfo,
228+
SchemeBoardInfo));
229+
} else {
230+
const TActorId newInstance = as->Register(CreateStateStorageProxy(StateStorageInfo, BoardInfo, SchemeBoardInfo),
231+
TMailboxType::ReadAsFilled, AppData()->SystemPoolId);
232+
const TActorId stubInstance = as->RegisterLocalService(MakeStateStorageProxyID(), newInstance);
233+
TActivationContext::Send(new IEventHandle(TEvents::TSystem::Poison, 0, stubInstance, newInstance, nullptr, 0));
234+
StateStorageProxyConfigured = true;
235+
}
228236
}
229237

230238
void TNodeWarden::ApplyStaticServiceSet(const NKikimrBlobStorage::TNodeWardenServiceSet& ss) {

0 commit comments

Comments
 (0)