Skip to content

Commit 42dcdfa

Browse files
committed
Rename "add" algorithm and mode to "maintain"
1 parent 891d7d0 commit 42dcdfa

File tree

3 files changed

+19
-12
lines changed

3 files changed

+19
-12
lines changed

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ Similar tools:
3232
days: 30
3333
prometheus_stats: "/tmp/prometheus-textcollect-partition-manager.prom"
3434
EOF
35-
→ partition-manager --config /tmp/partman.conf.yml add --noop
35+
→ partition-manager --config /tmp/partman.conf.yml maintain --noop
3636
INFO:root:No-op mode
3737
INFO:partition:Evaluating Table dogs (duration=30 days, 0:00:00) (pos={'id': 150})
3838
INFO:partition:Table dogs planned SQL: ALTER TABLE `dogs` REORGANIZE PARTITION `p_20201204` INTO (PARTITION `p_20210422` VALUES LESS THAN (221), PARTITION `p_20210522` VALUES LESS THAN MAXVALUE);
@@ -53,7 +53,7 @@ dogs:
5353
→ python3 -m pip install --editable .
5454
→ partition-manager --log-level=debug \
5555
--mariadb test_tools/fake_mariadb.sh \
56-
add --noop --table tablename
56+
maintain --noop --table tablename
5757
DEBUG:root:Auto_Increment column identified as id
5858
DEBUG:root:Partition range column identified as id
5959
DEBUG:root:Found partition before = (100)
@@ -110,10 +110,10 @@ orders:
110110

111111
- At start, if any configuration file specified as a CLI argument, read that configuration file to set all other values.
112112
- Then, process all remaining command line arguments, overriding values loaded from the configuration file in case of conflicts.
113-
- From those command-line arguments, determine whether to collect statistics `stats`, determine an initial partition layout `bootstrap`, or operate in the normal `add` mode.
113+
- From those command-line arguments, determine whether to collect statistics `stats`, determine an initial partition layout `bootstrap`, or operate in the normal `maintain` mode.
114114
- Use the configuration information as inputs to the required algorithm.
115115

116-
## "Add" Algorithm
116+
## "Maintain" Algorithm
117117

118118
The core algorithm is implemented in a method `plan_partition_changes` in `table_append_partition.py`. That algorithm is:
119119

@@ -152,13 +152,13 @@ Procedure:
152152
- Append the new partition to the intended empty partition list.
153153
- Return the lists of non-empty partitions, the current empty partitions, and the post-algorithm intended empty partitions.
154154

155-
### "Add" Finalization
155+
### "Maintain" Finalization
156156

157157
The results of the algorithm are converted into `ALTER` statements; if the user configured `--noop` they're emitted to console and the logs for each table. If not set to `--noop`, the application will execute the ALTERs at the database server and emit the results, including execution time as prometheus statistics if so configured.
158158

159159
## "Bootstrap" Algorithm
160160

161-
The bootstrap mode is a limited form of the "Add" Algorithm, using a temporary state file to determine rates-of-change. The bootstrap mode also does not limit itself to only affecting empty partitions, it can and will request changes that will prmopt row copies, in order to prepare a table for future use of the "Add" algorithm.
161+
The bootstrap mode is a limited form of the "Maintain" Algorithm, using a temporary state file to determine rates-of-change. The bootstrap mode also does not limit itself to only affecting empty partitions, it can and will request changes that will prmopt row copies, in order to prepare a table for future use of the "Maintain" algorithm.
162162

163163
# TODOs
164164

partitionmanager/cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ def partition_cmd(args):
173173

174174

175175
SUBPARSERS = PARSER.add_subparsers(dest="subparser_name")
176-
PARTITION_PARSER = SUBPARSERS.add_parser("add", help="add partitions")
176+
PARTITION_PARSER = SUBPARSERS.add_parser("maintain", help="maintain partitions")
177177
PARTITION_PARSER.add_argument(
178178
"--noop",
179179
"-n",

partitionmanager/cli_test.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def get_config_from_args_and_yaml(args, yaml, time):
3333
def run_partition_cmd_yaml(yaml):
3434
with tempfile.NamedTemporaryFile() as tmpfile:
3535
insert_into_file(tmpfile, yaml)
36-
args = PARSER.parse_args(["--config", tmpfile.name, "add"])
36+
args = PARSER.parse_args(["--config", tmpfile.name, "maintain"])
3737
return partition_cmd(args)
3838

3939

@@ -51,7 +51,7 @@ def test_partition_cmd_no_exec(self):
5151
[
5252
"--mariadb",
5353
str(nonexistant_exec),
54-
"add",
54+
"maintain",
5555
"--noop",
5656
"--table",
5757
"testtable",
@@ -62,7 +62,14 @@ def test_partition_cmd_no_exec(self):
6262

6363
def test_partition_cmd_noop(self):
6464
args = PARSER.parse_args(
65-
["--mariadb", str(fake_exec), "add", "--noop", "--table", "testtable_noop"]
65+
[
66+
"--mariadb",
67+
str(fake_exec),
68+
"maintain",
69+
"--noop",
70+
"--table",
71+
"testtable_noop",
72+
]
6673
)
6774
output = partition_cmd_at_time(args, datetime(2020, 11, 8, tzinfo=timezone.utc))
6875

@@ -83,7 +90,7 @@ def test_partition_cmd_noop(self):
8390

8491
def test_partition_cmd_final(self):
8592
args = PARSER.parse_args(
86-
["--mariadb", str(fake_exec), "add", "--table", "testtable_commit"]
93+
["--mariadb", str(fake_exec), "maintain", "--table", "testtable_commit"]
8794
)
8895
output = partition_cmd_at_time(args, datetime(2020, 11, 8, tzinfo=timezone.utc))
8996

@@ -107,7 +114,7 @@ def test_partition_cmd_several_tables(self):
107114
[
108115
"--mariadb",
109116
str(fake_exec),
110-
"add",
117+
"maintain",
111118
"--table",
112119
"testtable",
113120
"another_table",

0 commit comments

Comments
 (0)