fix UI 503s under checkpoint load
- Store: skip identical CT checkpoint writes (CertSpotter calls StoreLogState per batch across 64 logs; hashing the state avoids redundant writes). - webui: cache /api/stats for 10s and raise API query timeouts; UI polls, so repeated aggregate queries no longer queue behind checkpoint bursts. - reword discovery detail (no 'name enumeration' for S3/GCS; only Azure uses a container list).
This commit is contained in:
1 parent
32035d0b9d
commit
1ce5700cec
6 files changed
+50
-14
No files matched your search
+12
-1
@@ -2,6 +2,7 @@ package store
|
||||
|
||||
import (
|
||||
"context"
|
||||
"crypto/sha256"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"log"
|
||||
@@ -35,11 +36,21 @@ func (s *Store) StoreLogState(ctx context.Context, logID monitor.LogID, state *m
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
key := logID.Base64URLString()
|
||||
hash := sha256.Sum256(data)
|
||||
s.stateMu.Lock()
|
||||
if prev, ok := s.lastState[key]; ok && prev == hash {
|
||||
s.stateMu.Unlock()
|
||||
return nil // unchanged; CertSpotter calls this per batch
|
||||
}
|
||||
s.lastState[key] = hash
|
||||
s.stateMu.Unlock()
|
||||
|
||||
_, err = s.pool.Exec(ctx, `
|
||||
INSERT INTO ct_checkpoints (log_id, state, updated_at)
|
||||
VALUES ($1, $2, now())
|
||||
ON CONFLICT (log_id) DO UPDATE SET state = EXCLUDED.state, updated_at = now()`,
|
||||
logID.Base64URLString(), data)
|
||||
key, data)
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ package store
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/jackc/pgx/v5"
|
||||
@@ -20,6 +21,9 @@ import (
|
||||
type Store struct {
|
||||
pool *pgxpool.Pool
|
||||
metrics *metrics.Metrics
|
||||
|
||||
stateMu sync.Mutex
|
||||
lastState map[string][32]byte // per-log checkpoint hash; skip identical writes
|
||||
}
|
||||
|
||||
// Open connects to PostgreSQL. The pool is bounded; the caller configures the
|
||||
@@ -38,7 +42,7 @@ func Open(ctx context.Context, databaseURL string, maxConns int) (*Store, error)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &Store{pool: pool}, nil
|
||||
return &Store{pool: pool, lastState: make(map[string][32]byte)}, nil
|
||||
}
|
||||
|
||||
func (s *Store) SetMetrics(m *metrics.Metrics) { s.metrics = m }
|
||||
|
||||
Reference in new issue
Block a user