M18: cache DB-dump validation; skip re-validate on unchanged dumps
ListDumpFiles ran ValidateDump (line-by-line scan) for every dump on every ~5-min RefreshCache cycle — wasted I/O+CPU on large customer dumps. ListDumpFiles now takes an optional cached(name,size,mod) lookup; on a (size+modtime) match it reuses the prior result and skips ValidateDump. settings.DBValidationCache gains Size+ModTime; listAllDumpFiles builds the lookup from the persisted cache and writes back only fresh validations (cache miss), so an unchanged dump triggers neither a re-validation nor a settings.json write each cycle. nil cached = legacy validate-always (back-compat). Tests: cache-hit skips validate (sentinel), cache-miss validates, nil validates.
This commit is contained in:
@@ -161,6 +161,11 @@ type DBValidationCache struct {
|
||||
TableCount int `json:"table_count"`
|
||||
HasHeader bool `json:"has_header"`
|
||||
Error string `json:"error,omitempty"`
|
||||
// M18: Size + ModTime let ListDumpFiles skip the expensive line-by-line re-validation on every
|
||||
// ~5-min scheduler cycle when the dump file is unchanged. A cache entry is a HIT only when both the
|
||||
// file size and (RFC3339, second-precision) modtime match the on-disk file.
|
||||
Size int64 `json:"size,omitempty"`
|
||||
ModTime string `json:"mod_time,omitempty"` // RFC3339 (UTC)
|
||||
}
|
||||
|
||||
// SetDebug enables or disables debug logging for settings operations.
|
||||
|
||||
Reference in New Issue
Block a user