@@ -118,7 +118,7 @@ func (l *Log) addPreChain(rw http.ResponseWriter, r *http.Request) {
118118
119119func (l * Log ) addChainOrPreChain (ctx context.Context , reqBody io.ReadCloser , checkType func (* PendingLogEntry ) error ) (response []byte , code int , err error ) {
120120 labels := prometheus.Labels {"error" : "" , "issuer" : "" , "root" : "" , "reused" : "" ,
121- "precert" : "" , "preissuer" : "" , "chain_len" : "" , "source" : "" }
121+ "precert" : "" , "preissuer" : "" , "chain_len" : "" , "low_priority" : "" , " source" : "" }
122122 defer func () {
123123 if err != nil {
124124 labels ["error" ] = errorCategory (err )
@@ -147,9 +147,11 @@ func (l *Log) addChainOrPreChain(ctx context.Context, reqBody io.ReadCloser, che
147147 if err != nil {
148148 return nil , http .StatusBadRequest , fmtErrorf ("invalid chain: %w" , err )
149149 }
150+ lowPriority := lowPriority (chain [0 ])
150151 labels ["chain_len" ] = fmt .Sprintf ("%d" , len (chain ))
151152 labels ["root" ] = x509util .NameToString (chain [len (chain )- 1 ].Subject )
152153 labels ["issuer" ] = x509util .NameToString (chain [0 ].Issuer )
154+ labels ["low_priority" ] = fmt .Sprintf ("%v" , lowPriority )
153155
154156 e := & PendingLogEntry {Certificate : chain [0 ].Raw }
155157 for _ , issuer := range chain [1 :] {
@@ -195,14 +197,17 @@ func (l *Log) addChainOrPreChain(ctx context.Context, reqBody io.ReadCloser, che
195197 return nil , http .StatusBadRequest , err
196198 }
197199
198- waitLeaf , source := l .addLeafToPool (ctx , e )
200+ waitLeaf , source := l .addLeafToPool (ctx , e , lowPriority )
199201 labels ["source" ] = source
200202 waitTimer := prometheus .NewTimer (l .m .AddChainWait )
201203 seq , err := waitLeaf (ctx )
202- if source == "sequencer" {
204+ if source == "sequencer" && err != errEvicted {
203205 waitTimer .ObserveDuration ()
204206 }
205- if err == errPoolFull {
207+ if err == errEvicted {
208+ labels ["source" ] = "evicted"
209+ }
210+ if err == errPoolFull || err == errEvicted {
206211 return nil , http .StatusServiceUnavailable , err
207212 } else if errors .As (err , new (SunsetLogError )) {
208213 return nil , http .StatusGone , err
@@ -236,6 +241,19 @@ func (l *Log) addChainOrPreChain(ctx context.Context, reqBody io.ReadCloser, che
236241 return rsp , http .StatusOK , nil
237242}
238243
244+ func lowPriority (c * x509.Certificate ) bool {
245+ if isPrecert , _ := ctfe .IsPrecertificate (c ); isPrecert {
246+ // The BRs allow at most 48 hours of backdating. A precertificate older
247+ // than that can't turn into a valid certificate anymore, so it must be
248+ // cross-posted.
249+ return time .Since (c .NotBefore ) >= 48 * time .Hour
250+ }
251+ // If a certificate has SCTs, it's already been logged. It'd be better to
252+ // verify the signatures, but this check is meant for when we are under load
253+ // and need to prioritize.
254+ return len (c .SCTList .SCTList ) > 0
255+ }
256+
239257func (l * Log ) getRoots (rw http.ResponseWriter , r * http.Request ) {
240258 roots := l .rootPool ().RawCertificates ()
241259 var res struct {
0 commit comments