Skip to content

Commit e627f55

Browse files
committed
Add read/write flag, authzReuse table
1 parent 38f03f1 commit e627f55

File tree

2 files changed

+26
-9
lines changed

2 files changed

+26
-9
lines changed

features/features.go

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -110,14 +110,21 @@ type Config struct {
110110
// unique "INSERT ... RETURNING" functionality.
111111
InsertAuthzsIndividually bool
112112

113-
// NewOrdersSchema causes the SA to write to and read from the updated
114-
// orders, authorizations, and validations tables.
115-
// - Inserts go solely to the new schema
116-
// - Updates go to whichver schema hosts the row being updated
113+
// ReadNewOrderSchema causes the SA to attempt to read from the new orders,
114+
// authorizations, and validations tables. This allows us to continue reading
115+
// from these tables even if we have to roll back the flag which causes us
116+
// to write to them.
117117
// - Simple select-by-id go to whichever schema hosts the row being selected
118118
// - Complex queries go solely to the new schema (this means that authz and
119119
// order reuse work only in the new schema).
120-
NewOrdersSchema bool
120+
ReadNewOrderSchema bool
121+
122+
// WriteNewOrderSchema causes the SA to write to the new orders,
123+
// authorizations, and validations tables. Do not enable this flag unless
124+
// ReadNewOrderSchema is also enabled.
125+
// - Inserts go solely to the new schema
126+
// - Updates go to whichver schema hosts the row being updated
127+
WriteNewOrderSchema bool
121128
}
122129

123130
var fMu = new(sync.RWMutex)

sa/db-next/boulder_sa/20240801000000_OrderSchema.sql

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
-- is populated only if an error occurs during finalization and the order moves
1111
-- to the "invalid" state; errors during validation are reflected elsewhere.
1212
CREATE TABLE `orders2` (
13-
`id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT,
13+
`id` bigint(20) UNSIGNED NOT NULL,
1414
`registrationID` bigint(20) UNSIGNED NOT NULL,
1515
`created` datetime NOT NULL,
1616
`expires` datetime NOT NULL,
@@ -30,7 +30,7 @@ CREATE TABLE `orders2` (
3030
-- "valid" or "invalid", and the validations column will be updated to point
3131
-- to a new row in the validations table containing the record of that attempt.
3232
CREATE TABLE `authorizations` (
33-
`id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT,
33+
`id` bigint(20) UNSIGNED NOT NULL,
3434
`registrationID` bigint(20) UNSIGNED NOT NULL,
3535
`identifierType` tinyint(4) NOT NULL,
3636
`identifierValue` varchar(255) NOT NULL,
@@ -42,7 +42,6 @@ CREATE TABLE `authorizations` (
4242
`status` tinyint(4) NOT NULL,
4343
`validations` json DEFAULT NULL,
4444
PRIMARY KEY (`id`),
45-
KEY `regID_identifier_status_expires_idx` (`registrationID`,`identifierValue`,`status`,`expires`,`identifierType`),
4645
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4
4746
PARTITION BY RANGE(id)
4847
(PARTITION p_start VALUES LESS THAN (MAXVALUE));
@@ -52,7 +51,7 @@ CREATE TABLE `authorizations` (
5251
-- including the validation method used, the resulting status (valid or
5352
-- invalid), and an opaque blob of our audit record.
5453
CREATE TABLE `validations` (
55-
`id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT,
54+
`id` bigint(20) UNSIGNED NOT NULL,
5655
`registrationID` bigint(20) UNSIGNED NOT NULL,
5756
`challenge` tinyint(4) NOT NULL,
5857
`attemptedAt` datetime NOT NULL,
@@ -63,9 +62,20 @@ CREATE TABLE `validations` (
6362
PARTITION BY RANGE(id)
6463
(PARTITION p_start VALUES LESS THAN (MAXVALUE));
6564

65+
-- The authzReuse table exists solely to allow cheap lookups of reusable authz
66+
-- IDs. This allos us to not have expensive indices on the authorizations table.
67+
CREATE TABLE `authzReuse` (
68+
`accountID_identifier` VARCHAR(300) NOT NULL,
69+
`authzID` VARCHAR(255) NOT NULL,
70+
`expires` DATETIME NOT NULL
71+
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4
72+
PARTITION BY RANGE(id)
73+
(PARTITION p_start VALUES LESS THAN (MAXVALUE));
74+
6675
-- +migrate Down
6776
-- SQL section 'Down' is executed when this migration is rolled back
6877

78+
DROP TABLE `authzReuse`;
6979
DROP TABLE `validations`;
7080
DROP TABLE `authorizations`;
7181
DROP TABLE `orders2`;

0 commit comments

Comments
 (0)