Skip to content

SQS-785: correct response to GetQueueUrl with custom queue name when throttling #5439

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
Show file tree
Hide file tree
Changes from 1 commit
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
22 changes: 11 additions & 11 deletions ydb/core/ymq/actor/action.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ class TActionActor
RequestId_,
UserName_,
GetQueueName(),
FolderId_,
configurationFlags)
);
}
Expand Down Expand Up @@ -637,17 +638,16 @@ class TActionActor
return;
}

if (TDerived::NeedExistingQueue()) {
if (ev->Get()->Throttled) {
MakeError(MutableErrorDesc(), NErrors::THROTTLING_EXCEPTION, "Too many requests for nonexistent queue.");
SendReplyAndDie();
return;
}
if (!ev->Get()->QueueExists) {
MakeError(MutableErrorDesc(), NErrors::NON_EXISTENT_QUEUE);
SendReplyAndDie();
return;
}
if (ev->Get()->Throttled) {
MakeError(MutableErrorDesc(), NErrors::THROTTLING_EXCEPTION, "Too many requests for nonexistent queue.");
SendReplyAndDie();
return;
}

if (TDerived::NeedExistingQueue() && !ev->Get()->QueueExists) {
MakeError(MutableErrorDesc(), NErrors::NON_EXISTENT_QUEUE);
SendReplyAndDie();
return;
}

Y_ABORT_UNLESS(SchemeCache_);
Expand Down
13 changes: 13 additions & 0 deletions ydb/core/ymq/actor/events.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ struct TSqsEvents {
TString RequestId;
TString UserName;
TString QueueName;
TString FolderId;
ui64 Flags = 0;

enum EFlags {
Expand All @@ -177,6 +178,18 @@ struct TSqsEvents {
, QueueName(name)
, Flags(flags)
{ }
TEvGetConfiguration(
TString requestId,
const TString& user,
const TString& name,
const TString& folderId,
ui64 flags = 0
) : RequestId(std::move(requestId))
, UserName(user)
, QueueName(name)
, FolderId(folderId)
, Flags(flags)
{ }
};

struct TQuoterResourcesForActions : public TAtomicRefCount<TQuoterResourcesForActions> {
Expand Down
26 changes: 17 additions & 9 deletions ydb/core/ymq/actor/service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -579,18 +579,26 @@ void TSqsService::HandleGetConfiguration(TSqsEvents::TEvGetConfiguration::TPtr&
}

const auto queueIt = user->Queues_.find(queueName);
if (queueIt == user->Queues_.end()) {
if (RequestQueueListForUser(user, reqId)) {
LWPROBE(QueueRequestCacheMiss, userName, queueName, reqId, ev->Get()->ToStringHeader());
RLOG_SQS_REQ_DEBUG(reqId, "Queue [" << userName << "/" << queueName << "] was not found in sqs service list. Requesting queues list");
user->GetConfigurationRequests_.emplace(queueName, std::move(ev));
} else {
AnswerThrottled(ev);
}
if (queueIt != user->Queues_.end()) {
ProcessConfigurationRequestForQueue(ev, user, queueIt->second);
return;
} else if (ev->Get()->FolderId) {
const auto byNameAndFolderIt = user->QueueByNameAndFolder_ .find(
std::make_pair(ev->Get()->QueueName, ev->Get()->FolderId)
);
if (byNameAndFolderIt != user->QueueByNameAndFolder_.end()) {
ProcessConfigurationRequestForQueue(ev, user, byNameAndFolderIt->second);
return;
}
}

ProcessConfigurationRequestForQueue(ev, user, queueIt->second);
if (RequestQueueListForUser(user, reqId)) {
LWPROBE(QueueRequestCacheMiss, userName, queueName, reqId, ev->Get()->ToStringHeader());
RLOG_SQS_REQ_DEBUG(reqId, "Queue [" << userName << "/" << queueName << "] was not found in sqs service list. Requesting queues list");
user->GetConfigurationRequests_.emplace(queueName, std::move(ev));
} else {
AnswerThrottled(ev);
}
}

void TSqsService::AnswerNotExists(TSqsEvents::TEvGetConfiguration::TPtr& ev, const TUserInfoPtr& userInfo) {
Expand Down
7 changes: 2 additions & 5 deletions ydb/tests/functional/sqs/cloud/test_yandex_cloud_mode.py
Original file line number Diff line number Diff line change
Expand Up @@ -880,8 +880,5 @@ def get_attributes_of_nonexistent_queue():
)
)

# Check that getting queue url with custom name still works
assert_that(
lambda: self._sqs_api.get_queue_url(custom_queue_name),
not_(raises(RuntimeError))
)
received_queue_url = self._sqs_api.get_queue_url(custom_queue_name)
assert received_queue_url == queue_url
Loading