Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Verify in WriteSessionActor (#2651) #2700

Merged
merged 2 commits into from
Mar 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions ydb/services/deprecated/persqueue_v0/grpc_pq_actor.h
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,8 @@ class TWriteSessionActor : public NActors::TActorBootstrapped<TWriteSessionActor
NPersQueue::TWriteRequest::TInit InitRequest;

TActorId PartitionChooser;

bool SessionClosed = false;
};

class TReadSessionActor : public TActorBootstrapped<TReadSessionActor> {
Expand Down
12 changes: 10 additions & 2 deletions ydb/services/deprecated/persqueue_v0/grpc_pq_write_actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,10 @@ void TWriteSessionActor::SetupCounters(const TString& cloudId, const TString& db


void TWriteSessionActor::Handle(TEvDescribeTopicsResponse::TPtr& ev, const TActorContext& ctx) {
Y_ABORT_UNLESS(State == ES_WAIT_SCHEME || State == ES_INITED);
if (State != ES_WAIT_SCHEME && State != ES_INITED) {
return CloseSession("erroneous internal state", NPersQueue::NErrorCode::ERROR, ctx);
}

auto& res = ev->Get()->Result;
Y_ABORT_UNLESS(res->ResultSet.size() == 1);

Expand Down Expand Up @@ -503,6 +506,11 @@ void TWriteSessionActor::ProceedPartition(const ui32 partition, const TActorCont
}

void TWriteSessionActor::CloseSession(const TString& errorReason, const NPersQueue::NErrorCode::EErrorCode errorCode, const NActors::TActorContext& ctx) {
if (SessionClosed) {
return;
}
SessionClosed = true;

if (errorCode != NPersQueue::NErrorCode::OK) {
if (InternalErrorCode(errorCode)) {
SLIErrors.Inc();
Expand Down Expand Up @@ -865,7 +873,7 @@ void TWriteSessionActor::LogSession(const TActorContext& ctx) {

void TWriteSessionActor::HandleWakeup(const TActorContext& ctx) {
if (State != ES_INITED) {
return;
return CloseSession("erroneous internal state", NPersQueue::NErrorCode::ERROR, ctx);
}

auto now = ctx.Now();
Expand Down
2 changes: 2 additions & 0 deletions ydb/services/persqueue_v1/actors/write_session_actor.h
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,8 @@ class TWriteSessionActor

TActorId PartitionWriterCache;
TActorId PartitionChooser;

bool SessionClosed = false;
};

}
Expand Down
9 changes: 8 additions & 1 deletion ydb/services/persqueue_v1/actors/write_session_actor.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -724,6 +724,10 @@ void TWriteSessionActor<UseMigrationProtocol>::DestroyPartitionWriterCache(const

template<bool UseMigrationProtocol>
void TWriteSessionActor<UseMigrationProtocol>::CloseSession(const TString& errorReason, const PersQueue::ErrorCode::ErrorCode errorCode, const NActors::TActorContext& ctx) {
if (SessionClosed) {
return;
}
SessionClosed = true;

if (errorCode != PersQueue::ErrorCode::OK) {

Expand Down Expand Up @@ -1503,7 +1507,10 @@ void TWriteSessionActor<UseMigrationProtocol>::Handle(TEvents::TEvWakeup::TPtr&

template<bool UseMigrationProtocol>
void TWriteSessionActor<UseMigrationProtocol>::RecheckACL(const TActorContext& ctx) {
Y_ABORT_UNLESS(State == ES_INITED);
if (State != ES_INITED) {
LOG_ERROR_S(ctx, NKikimrServices::PQ_WRITE_PROXY, "WriteSessionActor state is wrong. Actual state '" << (int)State << "'");
return CloseSession("erroneous internal state", PersQueue::ErrorCode::ERROR, ctx);
}

auto now = ctx.Now();

Expand Down
Loading