Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix a few provisioning update issues #160

Merged
merged 1 commit into from May 16, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 19 additions & 5 deletions dynamic_dynamodb/aws/dynamodb.py
Expand Up @@ -279,6 +279,13 @@ def update_table_provisioning(
if current_writes > writes:
writes = current_writes

# Return if we do not need to scale at all
if reads == current_reads and writes == current_writes:
logger.info(
'{0} - No need to scale up reads nor writes'.format(
table_name))
return

logger.info(
'{0} - Retrying to update provisioning, excluding any decreases. '
'Setting new reads to {1} and new writes to {2}'.format(
Expand Down Expand Up @@ -392,8 +399,8 @@ def update_gsi_provisioning(
:type retry_with_only_increase: bool
:param retry_with_only_increase: Set to True to ensure only increases
"""
current_reads = int(get_provisioned_table_read_units(table_name))
current_writes = int(get_provisioned_table_write_units(table_name))
current_reads = int(get_provisioned_gsi_read_units(table_name, gsi_name))
current_writes = int(get_provisioned_gsi_write_units(table_name, gsi_name))

if retry_with_only_increase:
# Ensure that we are only doing increases
Expand All @@ -402,10 +409,17 @@ def update_gsi_provisioning(
if current_writes > writes:
writes = current_writes

# Return if we do not need to scale at all
if reads == current_reads and writes == current_writes:
logger.info(
'{0} - GSI: {1} - No need to scale up reads nor writes'.format(
table_name, gsi_name))
return

logger.info(
'{0} - Retrying to update provisioning, excluding any decreases. '
'Setting new reads to {1} and new writes to {2}'.format(
table_name, reads, writes))
'{0} - GSI: {1} - Retrying to update provisioning, excluding any decreases. '
'Setting new reads to {2} and new writes to {3}'.format(
table_name, gsi_name, reads, writes))

# Check that we are in the right time frame
m_windows = get_gsi_option(table_key, gsi_key, 'maintenance_windows')
Expand Down
32 changes: 18 additions & 14 deletions dynamic_dynamodb/core/gsi.py
Expand Up @@ -203,10 +203,11 @@ def __ensure_provisioning_reads(
if consumed_read_units_percent >= num_read_checks_reset_percent:

logger.info(
'{0} - Resetting the number of consecutive '
'read checks. Reason: Consumed percent {1} is '
'greater than reset percent: {2}'.format(
'{0} - GSI: {1} - Resetting the number of consecutive '
'read checks. Reason: Consumed percent {2} is '
'greater than reset percent: {3}'.format(
table_name,
gsi_name,
consumed_read_units_percent,
num_read_checks_reset_percent))

Expand Down Expand Up @@ -266,9 +267,9 @@ def __ensure_provisioning_reads(

if current_read_units != calculated_provisioning:
logger.info(
'{0} - Resetting the number of consecutive '
'{0} - GSI: {1} - Resetting the number of consecutive '
'read checks. Reason: scale up event detected'.format(
table_name))
table_name, gsi_name))
num_consec_read_checks = 0
update_needed = True
updated_read_units = calculated_provisioning
Expand Down Expand Up @@ -305,8 +306,9 @@ def __ensure_provisioning_reads(
'Will not increase writes over gsi-max-provisioned-reads '
'limit ({0} writes)'.format(updated_read_units))

logger.info('{0} - Consecutive read checks {1}/{2}'.format(
logger.info('{0} - GSI: {1} - Consecutive read checks {2}/{3}'.format(
table_name,
gsi_name,
num_consec_read_checks,
num_read_checks_before_scale_down))

Expand Down Expand Up @@ -382,10 +384,11 @@ def __ensure_provisioning_writes(
if consumed_write_units_percent >= num_write_checks_reset_percent:

logger.info(
'{0} - Resetting the number of consecutive '
'write checks. Reason: Consumed percent {1} is '
'greater than reset percent: {2}'.format(
'{0} - GSI: {1} - Resetting the number of consecutive '
'write checks. Reason: Consumed percent {2} is '
'greater than reset percent: {3}'.format(
table_name,
gsi_name,
consumed_write_units_percent,
num_write_checks_reset_percent))

Expand Down Expand Up @@ -417,9 +420,9 @@ def __ensure_provisioning_writes(

if current_write_units != calculated_provisioning:
logger.info(
'{0} - Resetting the number of consecutive '
'{0} - GSI: {1} - Resetting the number of consecutive '
'write checks. Reason: scale up event detected'.format(
table_name))
table_name, gsi_name))
num_consec_write_checks = 0
update_needed = True
updated_write_units = calculated_provisioning
Expand All @@ -444,9 +447,9 @@ def __ensure_provisioning_writes(

if current_write_units != calculated_provisioning:
logger.info(
'{0} - Resetting the number of consecutive '
'{0} - GSI: {1} - Resetting the number of consecutive '
'write checks. Reason: scale up event detected'.format(
table_name))
table_name, gsi_name))
num_consec_write_checks = 0
update_needed = True
updated_write_units = calculated_provisioning
Expand Down Expand Up @@ -485,8 +488,9 @@ def __ensure_provisioning_writes(
gsi_name,
updated_write_units))

logger.info('{0} - Consecutive write checks {1}/{2}'.format(
logger.info('{0} - GSI: {1} - Consecutive write checks {2}/{3}'.format(
table_name,
gsi_name,
num_consec_write_checks,
num_write_checks_before_scale_down))

Expand Down