Skip to content

Commit

Permalink
fix failing on verify in sqs when throttling budget is over and actio…
Browse files Browse the repository at this point in the history
…n does not require existing queue
  • Loading branch information
siarheivesialou committed Apr 19, 2024
1 parent 389f5b4 commit 0a7ed69
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 4 deletions.
4 changes: 2 additions & 2 deletions ydb/core/ymq/actor/action.h
Original file line number Diff line number Diff line change
Expand Up @@ -649,6 +649,8 @@ class TActionActor
}
}

Y_ABORT_UNLESS(SchemeCache_);

bool isACLProtectedAccount = Cfg().GetForceAccessControl();
if (!IsCloud() && (SecurityToken_ || (Cfg().GetForceAccessControl() && (isACLProtectedAccount = IsACLProtectedAccount(UserName_))))) {
this->Become(&TActionActor::WaitAuthCheckMessages);
Expand All @@ -666,8 +668,6 @@ class TActionActor
return;
}

Y_ABORT_UNLESS(SchemeCache_);

RequestSchemeCache(GetActionACLSourcePath()); // this also checks that requested queue (if any) does exist
RequestTicketParser();
} else {
Expand Down
1 change: 1 addition & 0 deletions ydb/core/ymq/actor/service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -685,6 +685,7 @@ void TSqsService::AnswerThrottled(TSqsEvents::TEvGetConfiguration::TPtr& ev) {
RLOG_SQS_REQ_DEBUG(ev->Get()->RequestId, "Throttled because of too many requests for nonexistent queue [" << ev->Get()->QueueName << "] for user [" << ev->Get()->UserName << "] while getting configuration");
auto answer = MakeHolder<TSqsEvents::TEvConfiguration>();
answer->Throttled = true;
answer->SchemeCache = SchemeCache_;
Send(ev->Sender, answer.Release());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@
from ydb.tests.library.sqs.test_base import KikimrSqsTestBase


throttling_exception_pattern = ".*</Message><Code>ThrottlingException</Code>.*"

class TestSqsThrottlingOnNonexistentQueue(KikimrSqsTestBase):


def test_throttling_on_nonexistent_queue(self):
queue_url = self._create_queue_and_assert(self.queue_name, False, True)
nonexistent_queue_url = queue_url + "_nonex"
Expand All @@ -21,8 +24,6 @@ def get_attributes_of_nonexistent_queue():
except Exception:
pass

throttling_exception_pattern = ".*</Message><Code>ThrottlingException</Code>.*"

assert_that(
get_attributes_of_nonexistent_queue,
raises(
Expand All @@ -46,3 +47,25 @@ def get_attributes_of_nonexistent_queue():
pattern=throttling_exception_pattern
)
)

def test_action_which_does_not_requere_existing_queue(self):
queue_url = self._create_queue_and_assert(self.queue_name, False, True)
nonexistent_queue_url = queue_url + "_nonex"

def get_attributes_of_nonexistent_queue():
self._sqs_api.get_queue_attributes(nonexistent_queue_url)

# Draining budget
for _ in range(16):
try:
get_attributes_of_nonexistent_queue()
except Exception:
pass

assert_that(
lambda: self._sqs_api.get_queue_url(self.queue_name + "_nonex"),
raises(
RuntimeError,
pattern=throttling_exception_pattern
)
)

0 comments on commit 0a7ed69

Please sign in to comment.