Validate checks LTX file consistency across all databases and levels. SnapshotLevel (9) is excluded since snapshots are not contiguous.
(ctx context.Context)
| 831 | // Validate checks LTX file consistency across all databases and levels. |
| 832 | // SnapshotLevel (9) is excluded since snapshots are not contiguous. |
| 833 | func (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. |
| 862 | func (s *Store) monitorValidation(ctx context.Context) { |