letsencrypt / letsencrypt/boulder
Partition the Registrations table
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 5.8k
- Forks
- 649
- Avg merge
- 3d 23h
- Merged PRs (30d)
- 24
Description
The Registrations table cannot currently be partitioned because of its unique constraint on the jwk_sha256 column, which is not the primary key. The table currently looks like:
CREATE TABLE `registrations` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`jwk` mediumblob NOT NULL,
`jwk_sha256` varchar(255) NOT NULL,
`contact` varchar(191) CHARACTER SET utf8mb4 NOT NULL,
`agreement` varchar(255) NOT NULL,
`LockCol` bigint(20) NOT NULL,
`initialIP` binary(16) NOT NULL DEFAULT '\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0',
`createdAt` datetime NOT NULL,
`status` varchar(255) NOT NULL DEFAULT 'valid',
PRIMARY KEY (`id`),
UNIQUE KEY `jwk_sha256` (`jwk_sha256`),
KEY `initialIP_createdAt` (`initialIP`,`createdAt`)
)
The simplest way to partition this table is to replace the unique index on jwk_sha256 with one that doesn't force a key constraint, just a basic index on that column. However, Boulder currently relies on MariaDB to ensure no duplication occurs for a given JWK hash, so to partition this table we'll not only need to perform a DB migration similar to those in #5298 , but we'll also need to change the series of queries the SA does to explicitly attempt to look up by jwk_sha256 before inserting. To keep the same semantics as the unique index, the SELECT could be done with an exclusive transaction lock, but it might be better to code around the potential duplication. I can probably help with that if desired.
As far as partitioning, doing so on id is reasonable for the purposes of future growth, but so would partitioning by hash on something like jwk_sha256. However, current MariaDB can't partition by hash on a varchar type, so perhaps it's best to aim for doing so by id.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No files or tests are named. Start with the registrations schema and the SA query paths that look up jwk_sha256 before insertion, then review the migration approach in #5298. Done requires a partition-compatible index and migration, explicit duplicate prevention with the same semantics, and a chosen partitioning strategy.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go, mariadb
- Domain
- backend, databases
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 28/100