reduced the places where we probe hourly tables
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2026-01-21 11:44:13 +11:00
parent b77f8671da
commit 32d4a352dc
2 changed files with 5 additions and 21 deletions

View File

@@ -103,19 +103,9 @@ LIMIT ?
continue continue
} }
probed := false probed := false
hasRows := count.Valid && count.Int64 > 0 // If count is known and >0, trust it; if NULL, accept optimistically to avoid heavy probes.
hasRows := !count.Valid || count.Int64 > 0
start := time.Now() start := time.Now()
if !count.Valid {
probed = true
if ok, err := db.TableHasRows(ctx, dbConn, name); err == nil {
hasRows = ok
} else {
hasRows = false
if logger != nil {
logger.Debug("snapshot table probe failed", "table", name, "error", err)
}
}
}
if vcenter != "" && hasRows { if vcenter != "" && hasRows {
probed = true probed = true
vrows, qerr := querySnapshotRows(ctx, dbConn, name, []string{"VmId"}, `"Vcenter" = ? LIMIT 1`, vcenter) vrows, qerr := querySnapshotRows(ctx, dbConn, name, []string{"VmId"}, `"Vcenter" = ? LIMIT 1`, vcenter)

View File

@@ -137,16 +137,10 @@ ORDER BY snapshot_time ASC
if err := db.ValidateTableName(t.Table); err != nil { if err := db.ValidateTableName(t.Table); err != nil {
continue continue
} }
if t.Count.Valid { // Trust snapshot_count if present; otherwise optimistically include to avoid long probes.
if t.Count.Int64 <= 0 { if t.Count.Valid && t.Count.Int64 <= 0 {
continue continue
} }
} else {
hasRows, err := db.TableHasRows(ctx, dbConn, t.Table)
if err != nil || !hasRows {
continue
}
}
tables = append(tables, t) tables = append(tables, t)
} }
return tables, nil return tables, nil