Skip to content

Commit 880055e

Browse files
authored
FOR UPDATE
1 parent b0a65bd commit 880055e

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

sa/sa.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -792,7 +792,7 @@ func addRevokedCertificate(ctx context.Context, tx db.Executor, req *sapb.Revoke
792792
var row struct {
793793
Count int64
794794
}
795-
err := tx.SelectOne(ctx, &row, "SELECT COUNT(*) as count FROM revokedCertificates WHERE serial = ?", req.Serial)
795+
err := tx.SelectOne(ctx, &row, "SELECT COUNT(*) as count FROM revokedCertificates WHERE serial = ? FOR UPDATE", req.Serial)
796796
if err != nil {
797797
return fmt.Errorf("checking if certificate is already revoked: %w", err)
798798
}
@@ -812,8 +812,8 @@ func addRevokedCertificate(ctx context.Context, tx db.Executor, req *sapb.Revoke
812812
}
813813

814814
// We're guaranteed that this won't be a duplicate insert because we've
815-
// already checked for existence of a row with the same serial above, in the
816-
// same transaction.
815+
// already checked for existence of a row with the same serial above, using
816+
// a FOR UPDATE select in this same transaction.
817817
err = tx.Insert(ctx, &revokedCertModel{
818818
IssuerID: req.IssuerID,
819819
Serial: req.Serial,

0 commit comments

Comments
 (0)