Skip to content

fix(azurestoragequeues): scope queue name cache to Connection - #2679

Merged
auvipy merged 3 commits into
celery:mainfrom
kratos0718:fix-azurestoragequeues-scope-queue-cache
Sep 30, 2026
Merged

auvipy merged 3 commits into
celery:mainfrom
kratos0718:fix-azurestoragequeues-scope-queue-cache

Conversation

@kratos0718

Copy link
Copy Markdown
Contributor

Same class-attribute sharing that #2543 fixed for Azure Service Bus and #2676 for SQS, this time in the Azure Storage Queues transport.

Channel._queue_name_cache is a class attribute, and each channel fills it from its own storage account's list_queues(). A Connection to a second storage account then trusts the first account's listing: _ensure_queue finds the queue name in the cache, skips create_queue, and the send fails with ResourceNotFoundError: The specified queue does not exist, because that queue only exists in the first account.

The fix moves the cache onto Transport (one per Connection) and exposes it on Channel through a property. Channels of the same Connection still share it.

Testing:

  • Added test_queue_name_cache_is_not_shared_across_connections, which fails on main (the second account never calls create_queue) and passes with the change.
  • Reproduced it end to end against two local Azurite servers, where only the first one has an orders queue. On main, sending orders through the second Connection raises ResourceNotFoundError. With the change, the queue is created on the second server and the send succeeds.
  • Full t/unit: 1616 passed. pre-commit hooks pass on both files.

_noack_queues on this channel is also a class attribute, but nothing reads it (_get deletes every message regardless), so I left it alone to keep this focused.

Channel._queue_name_cache was a class attribute, so every Azure Storage
Queues channel in the process shared one dict of queue names, filled
from each storage account's list_queues(). A Connection to a second
storage account then trusts the first account's listing: _ensure_queue
finds the name in the cache, skips create_queue, and the send fails
with ResourceNotFoundError because the queue only exists in the first
account.

Move the cache onto the Transport, one per Connection, and expose it on
Channel through a property, the same approach as celery#2543 and celery#2676.
@codecov

codecov Bot commented Sep 27, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 84.35%. Comparing base (101b54b) to head (4dba372).
⚠️ Report is 2 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2679      +/-   ##
==========================================
+ Coverage   84.19%   84.35%   +0.15%     
==========================================
  Files          80       80              
  Lines       11310    11315       +5     
  Branches     1354     1354              
==========================================
+ Hits         9523     9545      +22     
+ Misses       1567     1552      -15     
+ Partials      220      218       -2     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

@auvipy
auvipy merged commit 21d4533 into celery:main Sep 30, 2026
36 of 39 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants