Skip to content

Commit

Permalink
issue #324: storing NProto::TFileStore in session state to use it in …
Browse files Browse the repository at this point in the history
…the two stage read implementation in TServiceActor (#400)
  • Loading branch information
qkrorlqr committed Feb 15, 2024
1 parent 3f39d51 commit 6a27364
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -792,21 +792,26 @@ void TStorageServiceActor::HandleSessionCreated(
msg->FileStore.GetFileSystemId(),
msg->ClientId);

const auto mediaKind = static_cast<NProto::EStorageMediaKind>(
msg->FileStore.GetStorageMediaKind());

session = State->CreateSession(
msg->ClientId,
msg->FileStore.GetFileSystemId(),
msg->FileStore,
msg->SessionId,
msg->SessionState,
msg->SessionSeqNo,
msg->ReadOnly,
static_cast<NProto::EStorageMediaKind>(msg->FileStore.GetStorageMediaKind()),
mediaKind,
std::move(stats),
actorId,
msg->TabletId);

Y_ABORT_UNLESS(session);
} else {
session->UpdateSessionState(msg->SessionState);
session->UpdateSessionState(
msg->SessionState,
msg->FileStore);
session->AddSubSession(msg->SessionSeqNo, msg->ReadOnly);
session->SessionActor = actorId;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,9 @@ void TStorageServiceActor::HandleDestroySession(
"Another create or destroy request is in progress"));
}

if (session->ClientId != clientId || session->FileSystemId != fsId) {
if (session->ClientId != clientId
|| session->FileStore.GetFileSystemId() != fsId)
{
return reply(ErrorInvalidSession(clientId, sessionId, seqNo));
}

Expand Down Expand Up @@ -265,7 +267,7 @@ void TStorageServiceActor::HandleDestroySession(
StorageConfig,
std::move(requestInfo),
session->ClientId,
session->FileSystemId,
session->FileStore.GetFileSystemId(),
session->SessionId,
seqNo);

Expand All @@ -281,7 +283,7 @@ void TStorageServiceActor::HandleSessionDestroyed(
auto* session = State->FindSession(msg->SessionId, msg->SeqNo);
if (session) {
session->CreateDestroyState = ESessionCreateDestroyState::STATE_NONE;
const auto fsId = session->FileSystemId;
const auto fsId = session->FileStore.GetFileSystemId();
const auto clientId = session->ClientId;
if (!State->RemoveSession(msg->SessionId, msg->SeqNo)) {
StatsRegistry->Unregister(fsId, clientId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ void TStorageServiceActor::RenderSessions(IOutputStream& out)
DumpFsLink(
out,
session.TabletId,
session.FileSystemId
session.FileStore.GetFileSystemId()
);
}
TABLED() { out << session.SessionId; }
Expand Down
4 changes: 2 additions & 2 deletions cloud/filestore/libs/storage/service/service_state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ TIncompleteRequest TInFlightRequest::ToIncompleteRequest(ui64 nowCycles) const

TSessionInfo* TStorageServiceState::CreateSession(
TString clientId,
TString fileSystemId,
NProto::TFileStore fileStore,
TString sessionId,
TString sessionState,
ui64 seqNo,
Expand All @@ -74,7 +74,7 @@ TSessionInfo* TStorageServiceState::CreateSession(
if (it == SessionById.end()) {
auto session = std::make_unique<TSessionInfo>();
session->ClientId = std::move(clientId);
session->FileSystemId = std::move(fileSystemId);
session->FileStore = std::move(fileStore);
session->SessionId = std::move(sessionId);
session->SessionState = std::move(sessionState);
session->MediaKind = mediaKind,
Expand Down
10 changes: 6 additions & 4 deletions cloud/filestore/libs/storage/service/service_state.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ struct TSessionInfo
: public TIntrusiveListItem<TSessionInfo>
{
TString ClientId;
TString FileSystemId;
NProto::TFileStore FileStore;
TString SessionId;
TString SessionState;
NCloud::NProto::EStorageMediaKind MediaKind;
Expand All @@ -87,7 +87,8 @@ struct TSessionInfo
ui64 TabletId = 0;

THashMap<ui64, std::pair<bool, TInstant>> SubSessions;
ESessionCreateDestroyState CreateDestroyState = ESessionCreateDestroyState::STATE_NONE;
ESessionCreateDestroyState CreateDestroyState =
ESessionCreateDestroyState::STATE_NONE;

bool ShouldStop = false;

Expand All @@ -102,9 +103,10 @@ struct TSessionInfo
}
}

void UpdateSessionState(TString state)
void UpdateSessionState(TString state, NProto::TFileStore fileStore)
{
SessionState = std::move(state);
FileStore = std::move(fileStore);
}

void AddSubSession(ui64 seqNo, bool readOnly)
Expand Down Expand Up @@ -172,7 +174,7 @@ class TStorageServiceState
public:
TSessionInfo* CreateSession(
TString clientId,
TString fileSystemId,
NProto::TFileStore fileStore,
TString sessionId,
TString sessionState,
ui64 seqNo,
Expand Down

0 comments on commit 6a27364

Please sign in to comment.