Commit 76279b0
authored
test: Remove queries containing DDL from unit tests (#8479)
DDL (Data Definition Language) operations such as `ALTER` and `TRUNCATE`
are extremely expensive in Vitess. Each time Vitess detects a DDL
statement, it triggers a full schema reload, rebuilding the in-memory
schema models that are used for query planning and routing.
Our Storage Authority, Registration Authority, bad-key-revoker (cmd),
and cert-checker (cmd) unit tests repeatedly execute `ALTER` (and some
`TRUNCATE`) statements during routine cleanup of every table in the
Boulder database at the end of each test case. This has the effect of
dramatically worse performance when running on Vitess.
The good news is that we can omit these executions entirely by fixing
our unit tests so they no longer make implicit assumptions about the
Registration ID of the account under test.
- Remove `ALTER TABLE ... AUTO_INCREMENT = 1` from cleanup to avoid
unnecessary DDL
- Replace per-table `SET FOREIGN_KEY_CHECKS` toggles with toggles at the
beginning and end of the transaction. Replacing tables (20) x 2
statements with just 2.
- Replace `TRUNCATE TABLE` with `DELETE FROM ... WHERE 1 = 1` to avoid
unnecessary DDL
- Remove implicit dependencies on `RegID = 1 (or 2 or 3 or 4)` in `ra`,
`sa`, and `cmd/bad-key-revoker` unit tests
The results on both MariaDB and Vitess are extremely good.
Local unit test times with ProxySQL + MariaDB:
SA: 7.1s to 2.5s
RA: 4.5s to 1.1s
Local unit test times with Vitess + MySQL 8.0:
SA: 43s to 2.7s
RA: 28s to 1.5s
Part of #77361 parent f676b96 commit 76279b0
File tree
5 files changed
+333
-313
lines changed- cmd/bad-key-revoker
- ra
- sa
- db-users
- test
5 files changed
+333
-313
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
247 | 247 | | |
248 | 248 | | |
249 | 249 | | |
250 | | - | |
| 250 | + | |
251 | 251 | | |
252 | 252 | | |
253 | 253 | | |
| |||
0 commit comments