Skip to content

Commit 7113031

Browse files
authored
sa: deprecate two feature flags (#8580)
StoreAuthzsInOrders and StoreARIReplacesInOrders have been deployed in prod. Also, ensure both flags are set in `config/sa.json`, and neither is set in `config-next/sa.json`. This removes all reads of the `orderToAuthz2` table, which will make it possible to drop the table.
1 parent cdbcd47 commit 7113031

14 files changed

Lines changed: 118 additions & 292 deletions

File tree

db/map_test.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -162,10 +162,6 @@ func TestTableFromQuery(t *testing.T) {
162162
query: "insert into `orders` (`ID`,`RegistrationID`,`Expires`,`Created`,`Error`,`CertificateSerial`,`BeganProcessing`) values (null,?,?,?,?,?,?)",
163163
expectedTable: "`orders`",
164164
},
165-
{
166-
query: "insert into `orderToAuthz2` (`OrderID`,`AuthzID`) values (?,?);",
167-
expectedTable: "`orderToAuthz2`",
168-
},
169165
{
170166
query: "UPDATE authz2 SET status = :status, attempted = :attempted, validationRecord = :validationRecord, validationError = :validationError, expires = :expires WHERE id = :id AND status = :pending",
171167
expectedTable: "authz2",

features/features.go

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ type Config struct {
2929
DOH bool
3030
IgnoreAccountContacts bool
3131
NoPendingAuthzReuse bool
32+
StoreAuthzsInOrders bool
33+
StoreARIReplacesInOrders bool
3234

3335
// ServeRenewalInfo exposes the renewalInfo endpoint in the directory and for
3436
// GET requests. WARNING: This feature is a draft and highly unstable.
@@ -72,20 +74,11 @@ type Config struct {
7274
// fails validation.
7375
AutomaticallyPauseZombieClients bool
7476

75-
// StoreARIReplacesInOrders causes the SA to store and retrieve the optional
76-
// ARI replaces field in the orders table.
77-
StoreARIReplacesInOrders bool
78-
7977
// DNSAccount01Enabled controls support for the dns-account-01 challenge
8078
// type. When enabled, the server can offer and validate this challenge
8179
// during certificate issuance. This flag must be set to true in the
8280
// RA, VA, and WFE2 services for full functionality.
8381
DNSAccount01Enabled bool
84-
85-
// StoreAuthzsInOrders causes the SA to write to the `authzs`
86-
// column in NewOrder and read from it in GetOrder. It should be enabled
87-
// after the migration to add that column has been run.
88-
StoreAuthzsInOrders bool
8982
}
9083

9184
var fMu = new(sync.RWMutex)

sa/database.go

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import (
1313
"github.com/letsencrypt/boulder/cmd"
1414
"github.com/letsencrypt/boulder/core"
1515
boulderDB "github.com/letsencrypt/boulder/db"
16-
"github.com/letsencrypt/boulder/features"
1716
blog "github.com/letsencrypt/boulder/log"
1817
)
1918

@@ -250,18 +249,9 @@ func initTables(dbMap *borp.DbMap) {
250249
dbMap.AddTableWithName(core.Certificate{}, "certificates").SetKeys(true, "ID")
251250
dbMap.AddTableWithName(certificateStatusModel{}, "certificateStatus").SetKeys(true, "ID")
252251
dbMap.AddTableWithName(fqdnSet{}, "fqdnSets").SetKeys(true, "ID")
253-
tableMap := dbMap.AddTableWithName(orderModel{}, "orders").SetKeys(true, "ID")
254-
if !features.Get().StoreARIReplacesInOrders {
255-
tableMap.ColMap("Replaces").SetTransient(true)
256-
}
257-
if !features.Get().StoreAuthzsInOrders {
258-
tableMap.ColMap("Authzs").SetTransient(true)
259-
}
260-
261-
dbMap.AddTableWithName(orderToAuthzModel{}, "orderToAuthz").SetKeys(false, "OrderID", "AuthzID")
252+
dbMap.AddTableWithName(orderModel{}, "orders").SetKeys(true, "ID")
262253
dbMap.AddTableWithName(orderFQDNSet{}, "orderFqdnSets").SetKeys(true, "ID")
263254
dbMap.AddTableWithName(authzModel{}, "authz2").SetKeys(true, "ID")
264-
dbMap.AddTableWithName(orderToAuthzModel{}, "orderToAuthz2").SetKeys(false, "OrderID", "AuthzID")
265255
dbMap.AddTableWithName(recordedSerialModel{}, "serials").SetKeys(true, "ID")
266256
dbMap.AddTableWithName(lintingCertModel{}, "precertificates").SetKeys(true, "ID")
267257
dbMap.AddTableWithName(keyHashModel{}, "keyHashToSerial").SetKeys(true, "ID")

sa/database_test.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,12 @@ func TestStrictness(t *testing.T) {
134134
if err != nil {
135135
t.Fatal(err)
136136
}
137-
_, err = dbMap.ExecContext(ctx, `insert into orderToAuthz2 set
138-
orderID=999999999999999999999999999,
139-
authzID=999999999999999999999999999;`)
137+
_, err = dbMap.ExecContext(ctx, `insert into serials set
138+
id=999999999999999999999999999,
139+
serial="abcd",
140+
registrationID=99,
141+
created="2026-01-01",
142+
expires="2026-02-01";`)
140143
if err == nil {
141144
t.Fatal("Expected error when providing out of range value, got none.")
142145
}

sa/db-next/boulder_sa/20250304000000_OrdersReplaces.sql

Lines changed: 0 additions & 9 deletions
This file was deleted.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../db/boulder_sa/20250304000000_OrdersReplaces.sql

sa/db-users/boulder_sa.sql

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ GRANT SELECT,INSERT on fqdnSets TO 'sa'@'localhost';
2222
GRANT SELECT,INSERT,UPDATE ON orders TO 'sa'@'localhost';
2323
GRANT SELECT,INSERT,DELETE ON orderFqdnSets TO 'sa'@'localhost';
2424
GRANT SELECT,INSERT,UPDATE ON authz2 TO 'sa'@'localhost';
25-
GRANT SELECT,INSERT ON orderToAuthz2 TO 'sa'@'localhost';
2625
GRANT INSERT,SELECT ON serials TO 'sa'@'localhost';
2726
GRANT SELECT,INSERT ON precertificates TO 'sa'@'localhost';
2827
GRANT SELECT,INSERT ON keyHashToSerial TO 'sa'@'localhost';
@@ -43,7 +42,6 @@ GRANT SELECT on fqdnSets TO 'sa_ro'@'localhost';
4342
GRANT SELECT ON orders TO 'sa_ro'@'localhost';
4443
GRANT SELECT ON orderFqdnSets TO 'sa_ro'@'localhost';
4544
GRANT SELECT ON authz2 TO 'sa_ro'@'localhost';
46-
GRANT SELECT ON orderToAuthz2 TO 'sa_ro'@'localhost';
4745
GRANT SELECT ON serials TO 'sa_ro'@'localhost';
4846
GRANT SELECT ON precertificates TO 'sa_ro'@'localhost';
4947
GRANT SELECT ON keyHashToSerial TO 'sa_ro'@'localhost';
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
-- +migrate Up
2+
-- SQL in section 'Up' is executed when this migration is applied
3+
4+
ALTER TABLE `orders` ADD COLUMN `replaces` varchar(255) DEFAULT NULL;
5+
6+
-- +migrate Down
7+
-- SQL section 'Down' is executed when this migration is rolled back
8+
9+
ALTER TABLE `orders` DROP COLUMN `replaces`;

sa/model.go

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -350,11 +350,6 @@ type orderModel struct {
350350
Authzs []byte
351351
}
352352

353-
type orderToAuthzModel struct {
354-
OrderID int64
355-
AuthzID int64
356-
}
357-
358353
func modelToOrder(om *orderModel) (*corepb.Order, error) {
359354
profile := ""
360355
if om.CertificateProfileName != nil {
@@ -1182,18 +1177,6 @@ func getAuthorizationStatuses(ctx context.Context, s db.Selector, ids []int64) (
11821177
return validities, nil
11831178
}
11841179

1185-
// authzForOrder retrieves the authorization IDs for an order.
1186-
func authzForOrder(ctx context.Context, s db.Selector, orderID int64) ([]int64, error) {
1187-
var v2IDs []int64
1188-
_, err := s.Select(
1189-
ctx,
1190-
&v2IDs,
1191-
"SELECT authzID FROM orderToAuthz2 WHERE orderID = ?",
1192-
orderID,
1193-
)
1194-
return v2IDs, err
1195-
}
1196-
11971180
// crlShardModel represents one row in the crlShards table. The ThisUpdate and
11981181
// NextUpdate fields are pointers because they are NULL-able columns.
11991182
type crlShardModel struct {

sa/sa.go

Lines changed: 5 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import (
2222
corepb "github.com/letsencrypt/boulder/core/proto"
2323
"github.com/letsencrypt/boulder/db"
2424
berrors "github.com/letsencrypt/boulder/errors"
25-
"github.com/letsencrypt/boulder/features"
2625
bgrpc "github.com/letsencrypt/boulder/grpc"
2726
"github.com/letsencrypt/boulder/identifier"
2827
blog "github.com/letsencrypt/boulder/log"
@@ -493,15 +492,11 @@ func (ssa *SQLStorageAuthority) NewOrderAndAuthzs(ctx context.Context, req *sapb
493492

494493
// Second, insert the new order.
495494
created := ssa.clk.Now()
496-
var encodedAuthzs []byte
497-
var err error
498-
if features.Get().StoreAuthzsInOrders {
499-
encodedAuthzs, err = proto.Marshal(&sapb.Authzs{
500-
AuthzIDs: allAuthzIds,
501-
})
502-
if err != nil {
503-
return nil, err
504-
}
495+
encodedAuthzs, err := proto.Marshal(&sapb.Authzs{
496+
AuthzIDs: allAuthzIds,
497+
})
498+
if err != nil {
499+
return nil, err
505500
}
506501

507502
om := orderModel{
@@ -518,22 +513,6 @@ func (ssa *SQLStorageAuthority) NewOrderAndAuthzs(ctx context.Context, req *sapb
518513
}
519514
orderID := om.ID
520515

521-
// Third, insert all of the orderToAuthz relations.
522-
inserter, err := db.NewMultiInserter("orderToAuthz2", []string{"orderID", "authzID"})
523-
if err != nil {
524-
return nil, err
525-
}
526-
for _, id := range allAuthzIds {
527-
err := inserter.Add([]any{orderID, id})
528-
if err != nil {
529-
return nil, err
530-
}
531-
}
532-
err = inserter.Insert(ctx, tx)
533-
if err != nil {
534-
return nil, err
535-
}
536-
537516
// Fourth, insert the FQDNSet entry for the order.
538517
err = addOrderFQDNSet(ctx, tx, identifier.FromProtoSlice(req.NewOrder.Identifiers), orderID, req.NewOrder.RegistrationID, req.NewOrder.Expires.AsTime())
539518
if err != nil {

0 commit comments

Comments
 (0)