Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
* [ct_hammer] support HTTPS and Bearer token for Authentication.
* [preloader] support Bearer token Authentication for non temporal logs.

### CTFE Storage Saving: Extra Data Issuance Chain Deduplication

* Suppress unnecessary duplicate key errors in the IssuanceChainStorage PostgreSQL implementation by @robstradling in https://github.com/google/certificate-transparency-go/pull/1678

## v1.3.1

* Add AllLogListSignatureURL by @AlexLaroche in https://github.com/google/certificate-transparency-go/pull/1634
Expand Down
15 changes: 2 additions & 13 deletions trillian/ctfe/storage/postgresql/postgresql.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,14 @@ import (
"errors"
"strings"

"github.com/jackc/pgerrcode"
"github.com/jackc/pgx/v5/pgconn"
_ "github.com/jackc/pgx/v5/stdlib"

"k8s.io/klog/v2"
)

const (
selectIssuanceChainByKeySQL = "SELECT c.ChainValue FROM IssuanceChain AS c WHERE c.IdentityHash = $1"
insertIssuanceChainSQL = "INSERT INTO IssuanceChain(IdentityHash, ChainValue) VALUES ($1, $2)"
insertIssuanceChainSQL = "INSERT INTO IssuanceChain(IdentityHash, ChainValue) VALUES ($1, $2) ON CONFLICT DO NOTHING"
)

// IssuanceChainStorage is a PostgreSQL implementation of the IssuanceChainStorage interface.
Expand Down Expand Up @@ -68,16 +66,7 @@ func (s *IssuanceChainStorage) FindByKey(ctx context.Context, key []byte) ([]byt
// Add inserts the key-value pair of issuance chain.
func (s *IssuanceChainStorage) Add(ctx context.Context, key []byte, chain []byte) error {
_, err := s.db.ExecContext(ctx, insertIssuanceChainSQL, key, chain)
if err != nil {
// Ignore duplicated key error.
var postgresqlErr *pgconn.PgError
if errors.As(err, &postgresqlErr) && postgresqlErr.Code == pgerrcode.UniqueViolation {
return nil
}
return err
}

return nil
return err
}

// open takes the data source name and returns the sql.DB object.
Expand Down
Loading