Skip to content

Commit 6e5a7d6

Browse files
authored
[SB] fixing link flow issues (Azure#36879)
* fixing link flow issues * add eh * pylint * add unittest * add todo * changelog
1 parent 0a8dfb5 commit 6e5a7d6

File tree

12 files changed

+28
-17
lines changed

12 files changed

+28
-17
lines changed

sdk/eventhub/azure-eventhub/azure/eventhub/_pyamqp/aio/_receiver_async.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,11 @@ async def _incoming_attach(self, frame):
5959
async def _incoming_transfer(self, frame):
6060
if self.network_trace:
6161
_LOGGER.debug("<- %r", TransferFrame(payload=b"***", *frame[:-1]), extra=self.network_trace_params)
62-
self.delivery_count += 1
6362
self.received_delivery_id = frame[1] # delivery_id
6463
# If more is false --> this is the last frame of the message
6564
if not frame[5]:
6665
self.current_link_credit -= 1
66+
self.delivery_count += 1
6767
if self.received_delivery_id is not None:
6868
self._first_frame = frame
6969
if not self.received_delivery_id and not self._received_payload:

sdk/eventhub/azure-eventhub/azure/eventhub/_pyamqp/aio/_session_async.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,7 @@ async def _outgoing_transfer(self, delivery, network_trace_params):
334334
delivery.transfer_state = SessionTransferState.OKAY
335335

336336
async def _incoming_transfer(self, frame):
337+
# TODO: should this be only if more=False?
337338
self.next_incoming_id += 1
338339
self.remote_outgoing_window -= 1
339340
self.incoming_window -= 1

sdk/eventhub/azure-eventhub/azure/eventhub/_pyamqp/receiver.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def _incoming_transfer(self, frame):
6060
# If more is false --> this is the last frame of the message
6161
if not frame[5]:
6262
self.current_link_credit -= 1
63-
self.delivery_count += 1
63+
self.delivery_count += 1
6464
self.received_delivery_id = frame[1] # delivery_id
6565
if self.received_delivery_id is not None:
6666
self._first_frame = frame

sdk/eventhub/azure-eventhub/azure/eventhub/_pyamqp/session.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,7 @@ def _outgoing_transfer(self, delivery, network_trace_params):
370370
delivery.transfer_state = SessionTransferState.OKAY
371371

372372
def _incoming_transfer(self, frame):
373+
# TODO: should this be only if more=False?
373374
self.next_incoming_id += 1
374375
self.remote_outgoing_window -= 1
375376
self.incoming_window -= 1

sdk/eventhub/azure-eventhub/tests/pyamqp_tests/unittest/test_link.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,10 @@ def test_receive_transfer_continuation_frame():
105105

106106
link._incoming_transfer(transfer_frame_one)
107107
assert link.current_link_credit == 2
108+
assert link.delivery_count == 1
108109
link._incoming_transfer(transfer_frame_two)
109110
assert link.current_link_credit == 2
111+
assert link.delivery_count == 1
110112
link._incoming_transfer(transfer_frame_three)
111-
assert link.current_link_credit == 1
113+
assert link.current_link_credit == 1
114+
assert link.delivery_count == 2

sdk/servicebus/azure-servicebus/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
- Fixed a bug where token refreshes were not happening on long running operations ([35717](https://github.com/Azure/azure-sdk-for-python/issues/35717))
88
- Fixed a bug where using TokenCredential to create a subscription with forwarding caused a `ResourceNotFoundError` ([36545](https://github.com/Azure/azure-sdk-for-python/pull/36545))
99
- Fixed a bug where messages received on one receiver could not be settled on another receiver over mgmt link ([35304](https://github.com/Azure/azure-sdk-for-python/issues/35304))
10+
- Addressed a bug where excess Link Credits were being allocated when large messages were being received ([34270](https://github.com/Azure/azure-sdk-for-python/issues/34270))
1011

1112
## 7.12.2 (2024-05-08)
1213

sdk/servicebus/azure-servicebus/azure/servicebus/_pyamqp/aio/_receiver_async.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,10 @@ async def _incoming_attach(self, frame):
5959
async def _incoming_transfer(self, frame):
6060
if self.network_trace:
6161
_LOGGER.debug("<- %r", TransferFrame(payload=b"***", *frame[:-1]), extra=self.network_trace_params)
62-
self.delivery_count += 1
6362
self.received_delivery_id = frame[1] # delivery_id
6463
# If more is false --> this is the last frame of the message
6564
if not frame[5]:
65+
self.delivery_count += 1
6666
self.current_link_credit -= 1
6767
if self.received_delivery_id is not None:
6868
self._first_frame = frame

sdk/servicebus/azure-servicebus/azure/servicebus/_pyamqp/aio/_session_async.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,7 @@ async def _outgoing_transfer(self, delivery, network_trace_params):
334334
delivery.transfer_state = SessionTransferState.OKAY
335335

336336
async def _incoming_transfer(self, frame):
337+
# TODO: should this be only if more=False?
337338
self.next_incoming_id += 1
338339
self.remote_outgoing_window -= 1
339340
self.incoming_window -= 1

sdk/servicebus/azure-servicebus/azure/servicebus/_pyamqp/receiver.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def _incoming_transfer(self, frame):
6060
# If more is false --> this is the last frame of the message
6161
if not frame[5]:
6262
self.current_link_credit -= 1
63-
self.delivery_count += 1
63+
self.delivery_count += 1
6464
self.received_delivery_id = frame[1] # delivery_id
6565
if self.received_delivery_id is not None:
6666
self._first_frame = frame

sdk/servicebus/azure-servicebus/azure/servicebus/_pyamqp/session.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,7 @@ def _outgoing_transfer(self, delivery, network_trace_params):
370370
delivery.transfer_state = SessionTransferState.OKAY
371371

372372
def _incoming_transfer(self, frame):
373+
# TODO: should this be only if more=False?
373374
self.next_incoming_id += 1
374375
self.remote_outgoing_window -= 1
375376
self.incoming_window -= 1

0 commit comments

Comments
 (0)