MCPcopy
hub / github.com/benbjohnson/litestream / Validate

Method Validate

store.go:833–859  ·  view source on GitHub ↗

Validate checks LTX file consistency across all databases and levels. SnapshotLevel (9) is excluded since snapshots are not contiguous.

(ctx context.Context)

Source from the content-addressed store, hash-verified

831// Validate checks LTX file consistency across all databases and levels.
832// SnapshotLevel (9) is excluded since snapshots are not contiguous.
833func (s *Store) Validate(ctx context.Context) (*ValidationResult, error) {
834 result := &ValidationResult{Valid: true}
835
836 s.mu.Lock()
837 dbs := s.dbs
838 levels := s.levels
839 s.mu.Unlock()
840
841 for _, db := range dbs {
842 if db.Replica == nil {
843 continue
844 }
845
846 for _, lvl := range levels {
847 errs, err := db.Replica.ValidateLevel(ctx, lvl.Level)
848 if err != nil {
849 return nil, fmt.Errorf("validate level %d for %s: %w", lvl.Level, db.Path(), err)
850 }
851 if len(errs) > 0 {
852 result.Valid = false
853 result.Errors = append(result.Errors, errs...)
854 }
855 }
856 }
857
858 return result, nil
859}
860
861// monitorValidation periodically runs validation checks on all databases.
862func (s *Store) monitorValidation(ctx context.Context) {

Callers 4

monitorValidationMethod · 0.95
TestStore_ValidateFunction · 0.95
OpenMethod · 0.45

Calls 4

ValidateLevelMethod · 0.80
LockMethod · 0.45
UnlockMethod · 0.45
PathMethod · 0.45

Tested by 2

TestStore_ValidateFunction · 0.76