Skip to content

Fixed releasing of non locked partitions #21650

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

Merged
merged 2 commits into from
Jul 29, 2025
Merged
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
28 changes: 24 additions & 4 deletions ydb/services/deprecated/persqueue_v0/grpc_pq_read_actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1125,14 +1125,22 @@ void TReadSessionActor::Handle(TEvPersQueue::TEvLockPartition::TPtr& ev, const T
ctx.Send(actorId, new TEvPQProxy::TEvLockPartition(0, 0, false, !ClientsideLocksAllowed));
}

void TReadSessionActor::Handle(TEvPQProxy::TEvPartitionStatus::TPtr& ev, const TActorContext&) {
void TReadSessionActor::Handle(TEvPQProxy::TEvPartitionStatus::TPtr& ev, const TActorContext& ctx) {
if (!ActualPartitionActor(ev->Sender))
return;

auto& evTopic = ev->Get()->Topic;
auto it = Partitions.find(std::make_pair(evTopic->GetClientsideName(), ev->Get()->Partition));
Y_ABORT_UNLESS(it != Partitions.end());
Y_ABORT_UNLESS(it->second.LockGeneration);
if (!it->second.LockGeneration) {
LOG_ALERT_S(ctx, NKikimrServices::PQ_READ_PROXY,
PQ_LOG_PREFIX << " the unlocked partition " << ev->Get()->Partition << " status has been requested");
CloseSession(
TStringBuilder() << "Internal server error, the unlocked partition " << ev->Get()->Partition << " status has been requested",
NPersQueue::NErrorCode::ERROR, ctx
);
return;
}

if (it->second.Releasing) //lock request for already released partition - ignore
return;
Expand Down Expand Up @@ -1219,7 +1227,17 @@ void TReadSessionActor::Handle(TEvPersQueue::TEvReleasePartition::TPtr& ev, cons
return;
}

Y_ABORT_UNLESS(!Partitions.empty());
auto onUnknownPartition = [&](auto& marker) {
LOG_ALERT_S(ctx, NKikimrServices::PQ_READ_PROXY, PQ_LOG_PREFIX << " Releasing unknown partition: " << record.ShortDebugString() << " " << marker);
CloseSession(
TStringBuilder() << "Internal server error, releasing unknown partition: " << record.ShortDebugString() << " " << marker,
NPersQueue::NErrorCode::ERROR, ctx
);
};

if (Partitions.empty()) {
return onUnknownPartition("#PQv0.01");
}

TActorId actorId = TActorId{};
auto jt = Partitions.begin();
Expand All @@ -1233,7 +1251,9 @@ void TReadSessionActor::Handle(TEvPersQueue::TEvReleasePartition::TPtr& ev, cons
}
}
}
Y_ABORT_UNLESS(actorId);
if (!actorId) {
return onUnknownPartition("#PQv0.02");
}

{
auto it = TopicCounters.find(name);
Expand Down
Loading