Skip to content

Commit

Permalink
A careful end to the write session (ydb-platform#2717)
Browse files Browse the repository at this point in the history
  • Loading branch information
nshestakov authored Mar 14, 2024
1 parent fef7607 commit e89e3eb
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 0 deletions.
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
5 changes: 5 additions & 0 deletions ydb/services/deprecated/persqueue_v0/grpc_pq_write_actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -506,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
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
4 changes: 4 additions & 0 deletions ydb/services/persqueue_v1/actors/write_session_actor.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -726,6 +726,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

0 comments on commit e89e3eb

Please sign in to comment.