refactor(store): unify logic and enhance logging for initial store sync (waitStoreSync)

This commit is contained in:
Pasha Sviderski committed 2026-09-08 12:04:26 +10:00
1 parent 0f6c03240b
commit 842f796e38
3 files changed
+102 -131

No files matched your search

-30
View File
@@ -3,7 +3,6 @@ package store
import (
"context"
_ "embed"
"encoding/hex"
"errors"
"fmt"
"log/slog"
@@ -107,35 +106,6 @@ func (s *Store) Version(ctx context.Context) (map[string]uint64, error) {
return versions, nil
}
type MissingChange struct {
ActorID string
StartVersion uint64
EndVersion uint64
}
// KnownMissingChanges returns a list of currently known missing changes in the Corrosion database.
func (s *Store) KnownMissingChanges(ctx context.Context) ([]MissingChange, error) {
rows, err := s.corro.QueryContext(ctx, "SELECT actor_id, start, end FROM __corro_bookkeeping_gaps")
if err != nil {
return nil, fmt.Errorf("query missing changes: %w", err)
}
defer rows.Close()
var changes []MissingChange
for rows.Next() {
var c MissingChange
var actorBytes []byte
if err = rows.Scan(&actorBytes, &c.StartVersion, &c.EndVersion); err != nil {
return nil, fmt.Errorf("scan missing change: %w", err)
}
c.ActorID = hex.EncodeToString(actorBytes)
changes = append(changes, c)
}
return changes, nil
}
func (s *Store) CreateMachine(ctx context.Context, m *pb.MachineInfo) error {
mJSON, err := protojson.Marshal(m)
if err != nil {