Skip to content

Commit 2bbd9d7

Browse files
committed
fix: run more aggressive compaction for sqlite/metrics
We put frequently updated resources there, so cut the maximum age from 1h30m to 15m. Signed-off-by: Andrey Smirnov <[email protected]> (cherry picked from commit 6a00bfd)
1 parent 2af4122 commit 2bbd9d7

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

internal/backend/runtime/omni/state_sqlite.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"database/sql"
1111
"fmt"
1212
"os"
13+
"time"
1314

1415
"github.com/cosi-project/runtime/pkg/resource"
1516
"github.com/cosi-project/runtime/pkg/state"
@@ -26,6 +27,9 @@ func newSQLitePersistentState(ctx context.Context, db *sql.DB, logger *zap.Logge
2627
st, err := sqlite.NewState(ctx, db, store.ProtobufMarshaler{},
2728
sqlite.WithLogger(logger),
2829
sqlite.WithTablePrefix("metrics_"),
30+
// run aggressive compaction, as we store frequently updated link counters here
31+
sqlite.WithCompactionInterval(5*time.Minute),
32+
sqlite.WithCompactMinAge(10*time.Minute),
2933
)
3034
if err != nil {
3135
return nil, fmt.Errorf("failed to create sqlite state: %w", err)

0 commit comments

Comments
 (0)