boulder/sa
Jacob Hoffman-Andrews 16235b6839 sa: wrap transactions in a function for commits/rollbacks (#4373)
In the current SA code, we need to remember to call Rollback on any error.
If we don't, we'll leave dangling transactions, which are hard to spot but eventually
clog up the database and cause availability problems.

This change attempts to deal with rollbacks more rigorously, by implementing a
withTransaction function that takes a closure as input. withTransaction opens
a transaction, applies a context.Context to it, and then runs the closure. If the
closure returns an error, withTransaction rolls back and return the error; otherwise
it commits and returns nil.

One of the quirks of this implementation is that it relies on the closure modifying
variables from its parent scope in order to return values. An alternate implementation
could define the return value of the closure as interface{}, nil, and have the calling
function do a type assertion. I'm seeking feedback on that; not sure yet which is cleaner.

This is a subset of the functions that need this treatment. I've got more coming, but
some of the changes break tests so I'm checking into why.

Updates #4337
2019-07-31 12:41:51 -07:00
..
_db SA: Deprecate FasterRateLimit feature flag (#4210) 2019-05-09 15:06:21 -04:00
_db-next sa: drop SCTReceipts table and assoc. code. (#4344) 2019-07-17 11:12:42 -07:00
proto SA: Remove CountCertificatesByExactNames RPC (#4318) 2019-07-02 09:30:44 -04:00
satest Consistently used stdlib context package (#4229) 2019-05-28 14:36:16 -04:00
authz.go sa: remove unused revokeAuthorizations functions. (#4351) 2019-07-22 13:51:19 -04:00
database.go sa: drop SCTReceipts table and assoc. code. (#4344) 2019-07-17 11:12:42 -07:00
database_test.go Switch to DSNs (#4044) 2019-02-11 10:46:07 -08:00
ip_range_test.go Remove all stray copyright headers and appends the initial line to LICENSE.txt (#1853) 2016-05-31 12:32:04 -07:00
metrics.go SA: refactor DB stat collection & collect more stats. (#4096) 2019-03-06 17:08:53 -08:00
model.go SA: Delete unused challenges (#4353) 2019-07-26 14:04:46 -04:00
model_test.go SA: use err with more context for bad JSON unmarshals. (#4194) 2019-05-02 14:15:47 -04:00
rate_limits.go ra/sa: clean up CountCertificatesExact. (#4309) 2019-06-28 12:57:14 -04:00
rate_limits_test.go ra/sa: clean up CountCertificatesExact. (#4309) 2019-06-28 12:57:14 -04:00
rollback.go Only wrap error given to `Rollback` when `tx.Rollback()` fails. (#3025) 2017-08-31 14:44:25 -04:00
rollback_test.go Only wrap error given to `Rollback` when `tx.Rollback()` fails. (#3025) 2017-08-31 14:44:25 -04:00
sa.go sa: wrap transactions in a function for commits/rollbacks (#4373) 2019-07-31 12:41:51 -07:00
sa_test.go SA: Delete unused challenges (#4353) 2019-07-26 14:04:46 -04:00
test-cert.der Store a DB of issued names. 2015-09-28 19:37:50 -07:00
test-cert2.der Implement rate limiting by domain name. 2015-10-04 21:04:26 -07:00
transaction.go sa: wrap transactions in a function for commits/rollbacks (#4373) 2019-07-31 12:41:51 -07:00
type-converter.go core: split identifier types into separate package. (#4225) 2019-05-23 13:24:41 -07:00
type-converter_test.go core: split identifier types into separate package. (#4225) 2019-05-23 13:24:41 -07:00
www.eff.org.der Add initial certificate status in SA. 2015-04-23 19:52:34 -07:00