X Tutup
Skip to content

Commit b3bc3d8

Browse files
committed
Add a MaxDBConns config parameter. (letsencrypt#1793)
1 parent 339405b commit b3bc3d8

File tree

16 files changed

+56
-25
lines changed

16 files changed

+56
-25
lines changed

cmd/admin-revoker/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ func setupContext(context *cli.Context) (rpc.RegistrationAuthorityClient, blog.L
5454

5555
dbURL, err := c.Revoker.DBConfig.URL()
5656
cmd.FailOnError(err, "Couldn't load DB URL")
57-
dbMap, err := sa.NewDbMap(dbURL)
57+
dbMap, err := sa.NewDbMap(dbURL, c.Revoker.DBConfig.MaxDBConns)
5858
cmd.FailOnError(err, "Couldn't setup database connection")
5959

6060
sac, err := rpc.NewStorageAuthorityClient(clientName, amqpConf, stats)

cmd/boulder-sa/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ func main() {
2323

2424
dbURL, err := saConf.DBConfig.URL()
2525
cmd.FailOnError(err, "Couldn't load DB URL")
26-
dbMap, err := sa.NewDbMap(dbURL)
26+
dbMap, err := sa.NewDbMap(dbURL, saConf.DBConfig.MaxDBConns)
2727
cmd.FailOnError(err, "Couldn't connect to SA database")
2828

2929
sai, err := sa.NewSQLStorageAuthority(dbMap, clock.Default(), logger)

cmd/cert-checker/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ func main() {
300300

301301
saDbURL, err := config.CertChecker.DBConfig.URL()
302302
cmd.FailOnError(err, "Couldn't load DB URL")
303-
saDbMap, err := sa.NewDbMap(saDbURL)
303+
saDbMap, err := sa.NewDbMap(saDbURL, config.CertChecker.DBConfig.MaxDBConns)
304304
cmd.FailOnError(err, "Could not connect to database")
305305

306306
pa, err := policy.New(config.PA.Challenges)

cmd/cert-checker/main_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ func init() {
4545
}
4646

4747
func BenchmarkCheckCert(b *testing.B) {
48-
saDbMap, err := sa.NewDbMap(vars.DBConnSA)
48+
saDbMap, err := sa.NewDbMap(vars.DBConnSA, 0)
4949
if err != nil {
5050
fmt.Println("Couldn't connect to database")
5151
return
@@ -81,7 +81,7 @@ func BenchmarkCheckCert(b *testing.B) {
8181
}
8282

8383
func TestCheckCert(t *testing.T) {
84-
saDbMap, err := sa.NewDbMap(vars.DBConnSA)
84+
saDbMap, err := sa.NewDbMap(vars.DBConnSA, 0)
8585
test.AssertNotError(t, err, "Couldn't connect to database")
8686
saCleanup := test.ResetSATestDatabase(t)
8787
defer func() {
@@ -179,7 +179,7 @@ func TestCheckCert(t *testing.T) {
179179
}
180180

181181
func TestGetAndProcessCerts(t *testing.T) {
182-
saDbMap, err := sa.NewDbMap(vars.DBConnSA)
182+
saDbMap, err := sa.NewDbMap(vars.DBConnSA, 0)
183183
test.AssertNotError(t, err, "Couldn't connect to database")
184184
fc := clock.NewFake()
185185

cmd/config.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,7 @@ type DBConfig struct {
259259
DBConnect string
260260
// A file containing a connect URL for the DB.
261261
DBConnectFile string
262+
MaxDBConns int
262263
}
263264

264265
// URL returns the DBConnect URL represented by this DBConfig object, either

cmd/expiration-mailer/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ func main() {
315315
// Configure DB
316316
dbURL, err := c.Mailer.DBConfig.URL()
317317
cmd.FailOnError(err, "Couldn't load DB URL")
318-
dbMap, err := sa.NewDbMap(dbURL)
318+
dbMap, err := sa.NewDbMap(dbURL, c.Mailer.DBConfig.MaxDBConns)
319319
cmd.FailOnError(err, "Could not connect to database")
320320

321321
amqpConf := c.Mailer.AMQP

cmd/expiration-mailer/main_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ func TestFindExpiringCertificates(t *testing.T) {
341341
Expires: testCtx.fc.Now().AddDate(0, 0, 87),
342342
}
343343

344-
setupDBMap, err := sa.NewDbMap(vars.DBConnSAFullPerms)
344+
setupDBMap, err := sa.NewDbMap(vars.DBConnSAFullPerms, 0)
345345
err = setupDBMap.Insert(certA)
346346
test.AssertNotError(t, err, "Couldn't add certA")
347347
err = setupDBMap.Insert(certB)
@@ -464,7 +464,7 @@ func TestCertIsRenewed(t *testing.T) {
464464
},
465465
}
466466

467-
setupDBMap, err := sa.NewDbMap(vars.DBConnSAFullPerms)
467+
setupDBMap, err := sa.NewDbMap(vars.DBConnSAFullPerms, 0)
468468
if err != nil {
469469
t.Fatal(err)
470470
}
@@ -565,7 +565,7 @@ func TestLifetimeOfACert(t *testing.T) {
565565
Status: core.OCSPStatusGood,
566566
}
567567

568-
setupDBMap, err := sa.NewDbMap(vars.DBConnSAFullPerms)
568+
setupDBMap, err := sa.NewDbMap(vars.DBConnSAFullPerms, 0)
569569
err = setupDBMap.Insert(certA)
570570
test.AssertNotError(t, err, "unable to insert Certificate")
571571
err = setupDBMap.Insert(certStatusA)
@@ -670,7 +670,7 @@ func TestDontFindRevokedCert(t *testing.T) {
670670
Status: core.OCSPStatusRevoked,
671671
}
672672

673-
setupDBMap, err := sa.NewDbMap(vars.DBConnSAFullPerms)
673+
setupDBMap, err := sa.NewDbMap(vars.DBConnSAFullPerms, 0)
674674
err = setupDBMap.Insert(certA)
675675
test.AssertNotError(t, err, "unable to insert Certificate")
676676
err = setupDBMap.Insert(certStatusA)
@@ -741,7 +741,7 @@ func TestDedupOnRegistration(t *testing.T) {
741741
Status: core.OCSPStatusGood,
742742
}
743743

744-
setupDBMap, err := sa.NewDbMap(vars.DBConnSAFullPerms)
744+
setupDBMap, err := sa.NewDbMap(vars.DBConnSAFullPerms, 0)
745745
err = setupDBMap.Insert(certA)
746746
test.AssertNotError(t, err, "Couldn't add certA")
747747
err = setupDBMap.Insert(certB)
@@ -782,7 +782,7 @@ type testCtx struct {
782782
func setup(t *testing.T, nagTimes []time.Duration) *testCtx {
783783
// We use the test_setup user (which has full permissions to everything)
784784
// because the SA we return is used for inserting data to set up the test.
785-
dbMap, err := sa.NewDbMap(vars.DBConnSAFullPerms)
785+
dbMap, err := sa.NewDbMap(vars.DBConnSAFullPerms, 0)
786786
if err != nil {
787787
t.Fatalf("Couldn't connect the database: %s", err)
788788
}

cmd/external-cert-importer/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ func main() {
152152
// Configure DB
153153
dbURL, err := c.PA.DBConfig.URL()
154154
cmd.FailOnError(err, "Couldn't load DB URL")
155-
dbMap, err := sa.NewDbMap(dbURL)
155+
dbMap, err := sa.NewDbMap(dbURL, c.PA.DBConfig.MaxDBConns)
156156
cmd.FailOnError(err, "Could not connect to database")
157157

158158
dbMap.AddTableWithName(core.ExternalCert{}, "externalCerts").SetKeys(false, "SHA1")

cmd/ocsp-responder/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ func main() {
145145

146146
if url.Scheme == "mysql+tcp" {
147147
logger.Info(fmt.Sprintf("Loading OCSP Database for CA Cert: %s", c.Common.IssuerCert))
148-
dbMap, err := sa.NewDbMap(config.Source)
148+
dbMap, err := sa.NewDbMap(config.Source, config.DBConfig.MaxDBConns)
149149
cmd.FailOnError(err, "Could not connect to database")
150150
sa.SetSQLDebug(dbMap, logger)
151151
source, err = makeDBSource(dbMap, c.Common.IssuerCert, logger)

cmd/ocsp-updater/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -571,7 +571,7 @@ func main() {
571571
// Configure DB
572572
dbURL, err := conf.DBConfig.URL()
573573
cmd.FailOnError(err, "Couldn't load DB URL")
574-
dbMap, err := sa.NewDbMap(dbURL)
574+
dbMap, err := sa.NewDbMap(dbURL, conf.DBConfig.MaxDBConns)
575575
cmd.FailOnError(err, "Could not connect to database")
576576

577577
cac, pubc, sac := setupClients(conf, stats)

0 commit comments

Comments
 (0)
X Tutup