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

Add NoValidRatesOfChangeException and don't emit ALTER errors for it #87

Merged
merged 2 commits into from
Mar 14, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion partitionmanager/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,10 @@ def do_partition(conf):
except partitionmanager.types.DatabaseCommandException as e:
log.warning("Failed to automatically handle %s: %s", table, e)
metrics.add("alter_errors", table.name, 1)
except partitionmanager.types.TableEmptyException:
except (
partitionmanager.types.TableEmptyException,
partitionmanager.types.NoValidRatesOfChangeException,
):
log.warning("Table %s appears to be empty. Skipping.", table)
jcjones marked this conversation as resolved.
Show resolved Hide resolved
except (ValueError, Exception) as e:
log.warning("Failed to handle %s: %s", table, e)
Expand Down
2 changes: 1 addition & 1 deletion partitionmanager/table_append_partition.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ def _get_weighted_position_increase_per_day_for_partitions(partitions):
log.error(
"No rates of change were valid for the partition list: %s", partitions
)
raise ValueError("No valid rates of change")
raise partitionmanager.types.NoValidRatesOfChangeException

# Initialize a list with a zero for each position
weighted_sums = [0] * partitions[0].num_columns
Expand Down
7 changes: 7 additions & 0 deletions partitionmanager/table_append_partition_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
DuplicatePartitionException,
NewPlannedPartition,
NoEmptyPartitionsAvailableException,
NoValidRatesOfChangeException,
InstantPartition,
SqlInput,
SqlQuery,
Expand Down Expand Up @@ -444,6 +445,12 @@ def test_get_weighted_position_increase_per_day_for_partitions(self):
),
[548.3636363636364],
)
with self.assertRaises(NoValidRatesOfChangeException):
_get_weighted_position_increase_per_day_for_partitions(
[
mkPPart("p_736563646E64", 1200000),
]
)

def test_predict_forward_position(self):
with self.assertRaises(ValueError):
Expand Down
4 changes: 4 additions & 0 deletions partitionmanager/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -625,3 +625,7 @@ class DatabaseCommandException(Exception):

class NoExactTimeException(Exception):
"""Raised if there's no exact time available for this partition."""


class NoValidRatesOfChangeException(Exception):
"""Raised if the table's rate of change cannot be calculated."""
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ name = "mariadb-sequential-partition-manager"
maintainers = [
{name = "J.C. Jones", email = "jc@letsencrypt.org"},
]
version = "0.4.0"
version = "0.4.1"
description = "Manage DB partitions based on sequential IDs"
license = {file = "LICENSE.txt"}
classifiers = [
Expand Down