Skip to content

Commit 6f22b9c

Browse files
Fix ThrottlingException raising in YMQ when doing GetQueueUrl with drained queue list budget (#3600)
1 parent b6a279d commit 6f22b9c

File tree

2 files changed

+58
-10
lines changed

2 files changed

+58
-10
lines changed

ydb/core/ymq/actor/action.h

+11-10
Original file line numberDiff line numberDiff line change
@@ -630,22 +630,23 @@ class TActionActor
630630
}
631631
}
632632

633-
if (ev->Get()->Throttled) {
634-
MakeError(MutableErrorDesc(), NErrors::THROTTLING_EXCEPTION, "Too many requests for nonexistent queue.");
635-
SendReplyAndDie();
636-
return;
637-
}
638-
639633
if (ev->Get()->Fail) {
640634
MakeError(MutableErrorDesc(), NErrors::INTERNAL_FAILURE, "Failed to get configuration.");
641635
SendReplyAndDie();
642636
return;
643637
}
644638

645-
if (TDerived::NeedExistingQueue() && !ev->Get()->QueueExists) {
646-
MakeError(MutableErrorDesc(), NErrors::NON_EXISTENT_QUEUE);
647-
SendReplyAndDie();
648-
return;
639+
if (TDerived::NeedExistingQueue()) {
640+
if (ev->Get()->Throttled) {
641+
MakeError(MutableErrorDesc(), NErrors::THROTTLING_EXCEPTION, "Too many requests for nonexistent queue.");
642+
SendReplyAndDie();
643+
return;
644+
}
645+
if (!ev->Get()->QueueExists) {
646+
MakeError(MutableErrorDesc(), NErrors::NON_EXISTENT_QUEUE);
647+
SendReplyAndDie();
648+
return;
649+
}
649650
}
650651

651652
bool isACLProtectedAccount = Cfg().GetForceAccessControl();

ydb/tests/functional/sqs/cloud/test_yandex_cloud_mode.py

+47
Original file line numberDiff line numberDiff line change
@@ -838,3 +838,50 @@ def test_cloud_double_create_queue(self, is_fifo, tables_format):
838838
time.sleep(1)
839839
queue_url2 = self._sqs_api.create_queue(self.queue_name, is_fifo=is_fifo)
840840
assert queue_url1 == queue_url2, f'{queue_url1} vs {queue_url2}'
841+
842+
@pytest.mark.parametrize(**TABLES_FORMAT_PARAMS)
843+
@pytest.mark.parametrize(**IS_FIFO_PARAMS)
844+
def test_not_throttling_with_custom_queue_name(self, is_fifo, tables_format):
845+
self._init_with_params(is_fifo, tables_format)
846+
847+
self._sqs_api = self._create_api_for_user(
848+
user_name='ignored',
849+
raise_on_error=True,
850+
force_private=True,
851+
iam_token=self.iam_token,
852+
folder_id=self.folder_id,
853+
)
854+
855+
custom_queue_name = 'MyCustomQueue'
856+
queue_url = self._sqs_api.create_queue(
857+
queue_name=self.queue_name,
858+
private_api=True,
859+
custom_name=custom_queue_name,
860+
)
861+
862+
nonexistent_queue_url = queue_url.replace(self.queue_name, self.queue_name + '_nonex')
863+
864+
def get_attributes_of_nonexistent_queue():
865+
self._sqs_api.get_queue_attributes(nonexistent_queue_url)
866+
867+
# Draining budget
868+
for _ in range(16):
869+
try:
870+
get_attributes_of_nonexistent_queue()
871+
except Exception:
872+
pass
873+
874+
# Check that there is no more budget
875+
assert_that(
876+
get_attributes_of_nonexistent_queue,
877+
raises(
878+
RuntimeError,
879+
pattern=".*<Code>ThrottlingException</Code>.*"
880+
)
881+
)
882+
883+
# Check that getting queue url with custom name still works
884+
assert_that(
885+
lambda: self._sqs_api.get_queue_url(custom_queue_name),
886+
not_(raises(RuntimeError))
887+
)

0 commit comments

Comments
 (0)