Skip to content

Commit

Permalink
Merge branch 'release-1.24.3'
Browse files Browse the repository at this point in the history
* release-1.24.3:
  Bumping version to 1.24.3
  Add changelog entries from botocore
  dynamodb BatchWriter._flush bug (#3279)
  • Loading branch information
aws-sdk-python-automation committed Jun 6, 2022
2 parents 437f52a + 92a1eb6 commit af95d33
Show file tree
Hide file tree
Showing 7 changed files with 136 additions and 10 deletions.
12 changes: 12 additions & 0 deletions .changes/1.24.3.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[
{
"category": "``chime-sdk-messaging``",
"description": "[``botocore``] This release adds support for searching channels by members via the SearchChannels API, removes required restrictions for Name and Mode in UpdateChannel API and enhances CreateChannel API by exposing member and moderator list as well as channel id as optional parameters.",
"type": "api-change"
},
{
"category": "``connect``",
"description": "[``botocore``] This release adds a new API, GetCurrentUserData, which returns real-time details about users' current activity.",
"type": "api-change"
}
]
7 changes: 7 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@
CHANGELOG
=========

1.24.3
======

* api-change:``chime-sdk-messaging``: [``botocore``] This release adds support for searching channels by members via the SearchChannels API, removes required restrictions for Name and Mode in UpdateChannel API and enhances CreateChannel API by exposing member and moderator list as well as channel id as optional parameters.
* api-change:``connect``: [``botocore``] This release adds a new API, GetCurrentUserData, which returns real-time details about users' current activity.


1.24.2
======

Expand Down
2 changes: 1 addition & 1 deletion boto3/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from boto3.session import Session

__author__ = 'Amazon Web Services'
__version__ = '1.24.2'
__version__ = '1.24.3'


# The default Boto3 session; autoloaded when needed.
Expand Down
13 changes: 6 additions & 7 deletions boto3/dynamodb/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,13 +145,12 @@ def _flush(self):
RequestItems={self._table_name: items_to_send}
)
unprocessed_items = response['UnprocessedItems']

if unprocessed_items and unprocessed_items[self._table_name]:
# Any unprocessed_items are immediately added to the
# next batch we send.
self._items_buffer.extend(unprocessed_items[self._table_name])
else:
self._items_buffer = []
if not unprocessed_items:
unprocessed_items = {}
item_list = unprocessed_items.get(self._table_name, [])
# Any unprocessed_items are immediately added to the
# next batch we send.
self._items_buffer.extend(item_list)
logger.debug(
"Batch write sent %s, unprocessed: %s",
len(items_to_send),
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ universal = 0

[metadata]
requires_dist =
botocore>=1.27.2,<1.28.0
botocore>=1.27.3,<1.28.0
jmespath>=0.7.1,<2.0.0
s3transfer>=0.6.0,<0.7.0

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@


requires = [
'botocore>=1.27.2,<1.28.0',
'botocore>=1.27.3,<1.28.0',
'jmespath>=0.7.1,<2.0.0',
's3transfer>=0.6.0,<0.7.0',
]
Expand Down
108 changes: 108 additions & 0 deletions tests/unit/dynamodb/test_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -411,3 +411,111 @@ def test_auto_dedup_for_dup_requests(self):
}
}
self.assert_batch_write_calls_are([first_batch, second_batch])

def test_added_unsent_request_not_flushed_put(self):
# If n requests that get sent fail to process where n = flush_amount
# and at least one more request gets created before the second attempt,
# then previously if n requests were successful on the next run and
# returned an empty dict, _item_buffer would be emptied before sending
# the next batch of n requests
self.client.batch_write_item.side_effect = [
{
'UnprocessedItems': {
self.table_name: [
{'PutRequest': {'Item': {'Hash': 'foo1'}}},
{'PutRequest': {'Item': {'Hash': 'foo2'}}},
],
},
},
{
'UnprocessedItems': {},
},
{
'UnprocessedItems': {},
},
]
self.batch_writer.put_item({'Hash': 'foo1'})
self.batch_writer.put_item({'Hash': 'foo2'})
self.batch_writer.put_item({'Hash': 'foo3'})
self.assertIn(
{'PutRequest': {'Item': {'Hash': 'foo3'}}},
self.batch_writer._items_buffer,
)
batch = {
'RequestItems': {
self.table_name: [
{'PutRequest': {'Item': {'Hash': 'foo1'}}},
{'PutRequest': {'Item': {'Hash': 'foo2'}}},
]
}
}
final_batch = {
'RequestItems': {
self.table_name: [
{'PutRequest': {'Item': {'Hash': 'foo3'}}},
{'PutRequest': {'Item': {'Hash': 'foo4'}}},
]
}
}
# same batch sent twice since all failed on first try
# and flush_items = 2
self.assert_batch_write_calls_are([batch, batch])
# test that the next two items get sent
self.batch_writer.put_item({'Hash': 'foo4'})
self.assert_batch_write_calls_are([batch, batch, final_batch])
# the buffer should be empty now
self.assertEqual(self.batch_writer._items_buffer, [])

def test_added_unsent_request_not_flushed_delete(self):
# If n requests that get sent fail to process where n = flush_amount
# and at least one more request gets created before the second attempt,
# then previously if n requests were successful on the next run and
# returned an empty dict, _item_buffer would be emptied before sending
# the next batch of n requests
self.client.batch_write_item.side_effect = [
{
'UnprocessedItems': {
self.table_name: [
{'DeleteRequest': {'Key': {'Hash': 'foo1'}}},
{'DeleteRequest': {'Key': {'Hash': 'foo2'}}},
],
},
},
{
'UnprocessedItems': {},
},
{
'UnprocessedItems': {},
},
]
self.batch_writer.delete_item({'Hash': 'foo1'})
self.batch_writer.delete_item({'Hash': 'foo2'})
self.batch_writer.delete_item({'Hash': 'foo3'})
self.assertIn(
{'DeleteRequest': {'Key': {'Hash': 'foo3'}}},
self.batch_writer._items_buffer,
)
batch = {
'RequestItems': {
self.table_name: [
{'DeleteRequest': {'Key': {'Hash': 'foo1'}}},
{'DeleteRequest': {'Key': {'Hash': 'foo2'}}},
]
}
}
final_batch = {
'RequestItems': {
self.table_name: [
{'DeleteRequest': {'Key': {'Hash': 'foo3'}}},
{'DeleteRequest': {'Key': {'Hash': 'foo4'}}},
]
}
}
# same batch sent twice since all failed on first try
# and flush_items = 2
self.assert_batch_write_calls_are([batch, batch])
# test that the next two items get sent
self.batch_writer.delete_item({'Hash': 'foo4'})
self.assert_batch_write_calls_are([batch, batch, final_batch])
# the buffer should be empty now
self.assertEqual(self.batch_writer._items_buffer, [])

0 comments on commit af95d33

Please sign in to comment.