Skip to content

Commit

Permalink
Viewer returns Failed to resolve database (#11841)
Browse files Browse the repository at this point in the history
Co-authored-by: AlexSm <[email protected]>
Co-authored-by: Raubzeug <[email protected]>
  • Loading branch information
3 people authored Nov 29, 2024
1 parent 375629c commit dda2bc2
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 21 deletions.
24 changes: 16 additions & 8 deletions ydb/core/viewer/json_pipe_req.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,9 @@ TViewerPipeClient::TRequestResponse<TEvTxProxySchemeCache::TEvNavigateKeySetResu
void TViewerPipeClient::RequestTxProxyDescribe(const TString& path) {
THolder<TEvTxUserProxy::TEvNavigate> request(new TEvTxUserProxy::TEvNavigate());
request->Record.MutableDescribePath()->SetPath(path);
if (!Event->Get()->UserToken.empty()) {
request->Record.SetUserToken(Event->Get()->UserToken);
}
SendRequest(MakeTxProxyID(), request.Release());
}

Expand Down Expand Up @@ -763,13 +766,15 @@ void TViewerPipeClient::HandleResolveResource(TEvTxProxySchemeCache::TEvNavigate
SharedDatabase = CanonizePath(entry.Path);
if (SharedDatabase == AppData()->TenantName) {
Direct = true;
return Bootstrap(); // retry bootstrap without redirect this time
Bootstrap(); // retry bootstrap without redirect this time
} else {
DatabaseBoardInfoResponse = MakeRequestStateStorageEndpointsLookup(SharedDatabase);
}
DatabaseBoardInfoResponse = MakeRequestStateStorageEndpointsLookup(SharedDatabase);
} else {
ReplyAndPassAway(GetHTTPBADREQUEST("text/plain", "Failed to resolve database - shared database not found"));
return ReplyAndPassAway(GetHTTPBADREQUEST("text/plain", "Failed to resolve database - shared database not found"));
}
}
RequestDone();
}

void TViewerPipeClient::HandleResolveDatabase(TEvTxProxySchemeCache::TEvNavigateKeySetResult::TPtr& ev) {
Expand All @@ -780,24 +785,27 @@ void TViewerPipeClient::HandleResolveDatabase(TEvTxProxySchemeCache::TEvNavigate
if (entry.DomainInfo && entry.DomainInfo->ResourcesDomainKey && entry.DomainInfo->DomainKey != entry.DomainInfo->ResourcesDomainKey) {
ResourceNavigateResponse = MakeRequestSchemeCacheNavigate(TPathId(entry.DomainInfo->ResourcesDomainKey));
Become(&TViewerPipeClient::StateResolveResource);
return;
} else {
DatabaseBoardInfoResponse = MakeRequestStateStorageEndpointsLookup(CanonizePath(entry.Path));
}
DatabaseBoardInfoResponse = MakeRequestStateStorageEndpointsLookup(CanonizePath(entry.Path));
} else {
ReplyAndPassAway(GetHTTPBADREQUEST("text/plain", "Failed to resolve database - not found"));
return ReplyAndPassAway(GetHTTPBADREQUEST("text/plain", "Failed to resolve database - not found"));
}
}
RequestDone();
}

void TViewerPipeClient::HandleResolve(TEvStateStorage::TEvBoardInfo::TPtr& ev) {
if (DatabaseBoardInfoResponse) {
DatabaseBoardInfoResponse->Set(std::move(ev));
if (DatabaseBoardInfoResponse->IsOk()) {
ReplyAndPassAway(MakeForward(GetNodesFromBoardReply(DatabaseBoardInfoResponse->GetRef())));
return ReplyAndPassAway(MakeForward(GetNodesFromBoardReply(DatabaseBoardInfoResponse->GetRef())));
} else {
ReplyAndPassAway(GetHTTPBADREQUEST("text/plain", "Failed to resolve database - no nodes found"));
Direct = true;
Bootstrap(); // retry bootstrap without redirect this time
}
}
RequestDone();
}

void TViewerPipeClient::HandleTimeout() {
Expand Down
23 changes: 10 additions & 13 deletions ydb/core/viewer/viewer_tabletinfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,11 @@ class TJsonTabletInfo : public TJsonWhiteboardRequest<TEvWhiteboard::TEvTabletSt
}
const auto& params(Event->Get()->Request.GetParams());
TBase::RequestSettings.Timeout = FromStringWithDefault<ui32>(params.Get("timeout"), 10000);
if (Database) {
RegisterWithSameMailbox(CreateBoardLookupActor(MakeEndpointsBoardPath(Database), TBase::SelfId(), EBoardLookupMode::Second));

if (DatabaseBoardInfoResponse && DatabaseBoardInfoResponse->IsOk()) {
TBase::RequestSettings.FilterNodeIds = TBase::GetNodesFromBoardReply(DatabaseBoardInfoResponse->GetRef());
} else if (Database) {
RequestStateStorageEndpointsLookup(Database);
Become(&TThis::StateRequestedLookup, TDuration::MilliSeconds(TBase::RequestSettings.Timeout), new TEvents::TEvWakeup());
return;
}
Expand All @@ -103,13 +106,7 @@ class TJsonTabletInfo : public TJsonWhiteboardRequest<TEvWhiteboard::TEvTabletSt
if (params.Has("path")) {
TBase::RequestSettings.Timeout = FromStringWithDefault<ui32>(params.Get("timeout"), 10000);
IsBase64Encode = FromStringWithDefault<bool>(params.Get("base64"), IsBase64Encode);
THolder<TEvTxUserProxy::TEvNavigate> request(new TEvTxUserProxy::TEvNavigate());
if (!Event->Get()->UserToken.empty()) {
request->Record.SetUserToken(Event->Get()->UserToken);
}
NKikimrSchemeOp::TDescribePath* record = request->Record.MutableDescribePath();
record->SetPath(params.Get("path"));
TBase::Send(MakeTxProxyID(), request.Release());
RequestTxProxyDescribe(params.Get("path"));
Become(&TThis::StateRequestedDescribe, TDuration::MilliSeconds(TBase::RequestSettings.Timeout), new TEvents::TEvWakeup());
} else {
TBase::Bootstrap();
Expand All @@ -134,6 +131,7 @@ class TJsonTabletInfo : public TJsonWhiteboardRequest<TEvWhiteboard::TEvTabletSt
void Handle(TEvStateStorage::TEvBoardInfo::TPtr& ev) {
TBase::RequestSettings.FilterNodeIds = TBase::GetNodesFromBoardReply(ev);
CheckPath();
RequestDone();
}

TString GetColumnValue(const TCell& cell, const NKikimrSchemeOp::TColumnDescription& type) {
Expand Down Expand Up @@ -182,7 +180,7 @@ class TJsonTabletInfo : public TJsonWhiteboardRequest<TEvWhiteboard::TEvTabletSt
NScheme::TTypeInfo typeInfo = NKikimr::NScheme::TypeInfoFromProto(type.GetTypeId(), type.GetTypeInfo());
auto convert = NPg::PgNativeTextFromNativeBinary(cell.AsBuf(),typeInfo.GetPgTypeDesc());
return TStringBuilder() << '"' << (!convert.Error ? convert.Str : *convert.Error) << '"';;
}
}
case NScheme::NTypeIds::DyNumber: return "DyNumber";
case NScheme::NTypeIds::Uuid: return "Uuid";
default:
Expand Down Expand Up @@ -331,14 +329,13 @@ class TJsonTabletInfo : public TJsonWhiteboardRequest<TEvWhiteboard::TEvTabletSt
}
}
}
if (Tablets.empty()) {
ReplyAndPassAway();
} else {
if (!Tablets.empty()) {
TBase::Bootstrap();
for (auto tablet : Tablets) {
Request->Record.AddFilterTabletId(tablet.first);
}
}
RequestDone();
}

virtual void FilterResponse(NKikimrWhiteboard::TEvTabletStateResponse& response) override {
Expand Down

0 comments on commit dda2bc2

Please sign in to comment.