From d9525a0f27ff3818a207f1a571f7aa4e3b57f858 Mon Sep 17 00:00:00 2001 From: Michal Niewrzal Date: Fri, 21 Jul 2023 15:07:23 +0200 Subject: [PATCH] cmd/tools/migrate-segment-copies: fix placement scan from DB Placement can be null in DB and we need adjust scanning this column from DB. Additionally this change sets application name for DB connection. Change-Id: I3c7d6294f4a3e5e441160b2fd4aeafffe705ec76 --- cmd/tools/migrate-segment-copies/main.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/cmd/tools/migrate-segment-copies/main.go b/cmd/tools/migrate-segment-copies/main.go index a5337eed7..da2861569 100644 --- a/cmd/tools/migrate-segment-copies/main.go +++ b/cmd/tools/migrate-segment-copies/main.go @@ -81,7 +81,9 @@ func main() { func Migrate(ctx context.Context, log *zap.Logger, config Config) (err error) { defer mon.Task()(&ctx)(&err) - db, err := metabase.Open(ctx, log, config.MetabaseDB, metabase.Config{}) + db, err := metabase.Open(ctx, log, config.MetabaseDB, metabase.Config{ + ApplicationName: "migrate-segment-copies", + }) if err != nil { return errs.New("unable to connect %q: %w", config.MetabaseDB, err) } @@ -164,7 +166,7 @@ func MigrateSegments(ctx context.Context, log *zap.Logger, metabaseDB *metabase. RemoteAliasPieces []byte RootPieceID []byte RepairedAt *time.Time - Placement int64 + Placement *int64 } updates := []Update{} @@ -176,7 +178,7 @@ func MigrateSegments(ctx context.Context, log *zap.Logger, metabaseDB *metabase. var position int64 var remoteAliasPieces, rootPieceID []byte var repairedAt *time.Time - var placement int64 + var placement *int64 err := rows.Scan(&ancestorStreamID, &position, &remoteAliasPieces, &rootPieceID, &repairedAt, &placement) if err != nil { return err