Skip to content

Commit 67ec019

Browse files
authored
Add NoValidRatesOfChangeException and don't emit ALTER errors for it (#87)
* Add NoValidRatesOfChangeException and don't emit ALTER errors for it Fixes #86 * Add exception name to warning log
1 parent 0cb3786 commit 67ec019

File tree

5 files changed

+18
-4
lines changed

5 files changed

+18
-4
lines changed

partitionmanager/cli.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -360,8 +360,11 @@ def do_partition(conf):
360360
except partitionmanager.types.DatabaseCommandException as e:
361361
log.warning("Failed to automatically handle %s: %s", table, e)
362362
metrics.add("alter_errors", table.name, 1)
363-
except partitionmanager.types.TableEmptyException:
364-
log.warning("Table %s appears to be empty. Skipping.", table)
363+
except (
364+
partitionmanager.types.TableEmptyException,
365+
partitionmanager.types.NoValidRatesOfChangeException,
366+
) as e:
367+
log.warning("Table %s appears to be empty (%s). Skipping.", table, e)
365368
except (ValueError, Exception) as e:
366369
log.warning("Failed to handle %s: %s", table, e)
367370
metrics.add("alter_errors", table.name, 1)

partitionmanager/table_append_partition.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ def _get_weighted_position_increase_per_day_for_partitions(partitions):
287287
log.error(
288288
"No rates of change were valid for the partition list: %s", partitions
289289
)
290-
raise ValueError("No valid rates of change")
290+
raise partitionmanager.types.NoValidRatesOfChangeException
291291

292292
# Initialize a list with a zero for each position
293293
weighted_sums = [0] * partitions[0].num_columns

partitionmanager/table_append_partition_test.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
DuplicatePartitionException,
1010
NewPlannedPartition,
1111
NoEmptyPartitionsAvailableException,
12+
NoValidRatesOfChangeException,
1213
InstantPartition,
1314
SqlInput,
1415
SqlQuery,
@@ -444,6 +445,12 @@ def test_get_weighted_position_increase_per_day_for_partitions(self):
444445
),
445446
[548.3636363636364],
446447
)
448+
with self.assertRaises(NoValidRatesOfChangeException):
449+
_get_weighted_position_increase_per_day_for_partitions(
450+
[
451+
mkPPart("p_736563646E64", 1200000),
452+
]
453+
)
447454

448455
def test_predict_forward_position(self):
449456
with self.assertRaises(ValueError):

partitionmanager/types.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -625,3 +625,7 @@ class DatabaseCommandException(Exception):
625625

626626
class NoExactTimeException(Exception):
627627
"""Raised if there's no exact time available for this partition."""
628+
629+
630+
class NoValidRatesOfChangeException(Exception):
631+
"""Raised if the table's rate of change cannot be calculated."""

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ name = "mariadb-sequential-partition-manager"
77
maintainers = [
88
{name = "J.C. Jones", email = "jc@letsencrypt.org"},
99
]
10-
version = "0.4.0"
10+
version = "0.4.1"
1111
description = "Manage DB partitions based on sequential IDs"
1212
license = {file = "LICENSE.txt"}
1313
classifiers = [

0 commit comments

Comments
 (0)