X Tutup
Skip to content

Commit 8eb7272

Browse files
authored
SA: Use read-only connector for GetAuthorizations2 (letsencrypt#5815)
Add a feature flag which causes the SA to switch between using the traditional read-write database connector (pointed at the primary db) or the newer read-only database connector (usually pointed at a replica) when executing the `GetAuthorizations2` query.
1 parent 1e67f7b commit 8eb7272

File tree

4 files changed

+17
-4
lines changed

4 files changed

+17
-4
lines changed

features/featureflag_string.go

Lines changed: 3 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

features/features.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ const (
5252
// ServeRenewalInfo exposes the renewalInfo endpoint in the directory and for
5353
// GET requests. WARNING: This feature is a draft and highly unstable.
5454
ServeRenewalInfo
55+
// GetAuthzReadOnly causes the SA to use its read-only database connection
56+
// (which is generally pointed at a replica rather than the primary db) when
57+
// querying the authz2 table.
58+
GetAuthzReadOnly
5559
)
5660

5761
// List of features and their default value, protected by fMu
@@ -74,6 +78,7 @@ var features = map[FeatureFlag]bool{
7478
ECDSAForAll: false,
7579
StreamlineOrderAndAuthzs: false,
7680
ServeRenewalInfo: false,
81+
GetAuthzReadOnly: false,
7782
}
7883

7984
var fMu = new(sync.RWMutex)

sa/sa.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1597,7 +1597,13 @@ func (ssa *SQLStorageAuthority) GetAuthorizations2(ctx context.Context, req *sap
15971597
authzFields,
15981598
strings.Join(qmarks, ","),
15991599
)
1600-
_, err := ssa.dbMap.Select(
1600+
var dbMap *db.WrappedMap
1601+
if features.Enabled(features.GetAuthzReadOnly) {
1602+
dbMap = ssa.dbReadOnlyMap
1603+
} else {
1604+
dbMap = ssa.dbMap
1605+
}
1606+
_, err := dbMap.Select(
16011607
&authzModels,
16021608
query,
16031609
params...,

test/config-next/sa.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@
3131
},
3232
"features": {
3333
"FasterNewOrdersRateLimit": true,
34-
"StoreRevokerInfo": true
34+
"StoreRevokerInfo": true,
35+
"GetAuthzReadOnly": true
3536
}
3637
},
3738

0 commit comments

Comments
 (0)
X Tutup