Skip to content

Commit 11f831b

Browse files
committed
Honor migrator flag and add useful debugging (#1640)
This is a straightforward bug fix that wires up an existing migration config flag that wasn't being passed through, plus adds debug logging
1 parent 27869d2 commit 11f831b

3 files changed

Lines changed: 18 additions & 2 deletions

File tree

dev/local.env

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ export XMTPD_PAYER_PRIVATE_KEY=$XMTPD_SIGNER_PRIVATE_KEY
4646

4747
# Migration Server Options
4848
# Not enabled by default. DB Reader connection string should be set accordingly.
49-
export XMTPD_MIGRATION_SERVER_ENABLE=false
5049
export XMTPD_MIGRATION_PAYER_PRIVATE_KEY=$XMTPD_SIGNER_PRIVATE_KEY
5150
export XMTPD_MIGRATION_NODE_SIGNING_KEY=$XMTPD_SIGNER_PRIVATE_KEY
5251
# export XMTPD_MIGRATION_DB_READER_CONNECTION_STRING="postgres://postgres:xmtp@localhost:8765/postgres?sslmode=disable"
@@ -57,7 +56,6 @@ export XMTPD_MIGRATION_NODE_SIGNING_KEY=$XMTPD_SIGNER_PRIVATE_KEY
5756
# export XMTPD_MIGRATION_DB_NAMESPACE="xmtp"
5857

5958
# Migration Client Options
60-
export XMTPD_MIGRATION_CLIENT_ENABLE=false
6159
export XMTPD_MIGRATION_CLIENT_FROM_NODE_ID=100
6260

6361
# Reflection Options - Enable gRPC reflection for grpcurl/buf curl

pkg/server/server.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,10 @@ func NewBaseServer(
348348
),
349349
sync.WithPayerReportDomainSeparator(domainSeparator),
350350
sync.WithClientMetrics(clientMetrics),
351+
sync.WithMigration(sync.MigrationConfig{
352+
Enable: cfg.Options.MigrationClient.Enable,
353+
FromNodeID: cfg.Options.MigrationClient.FromNodeID,
354+
}),
351355
)
352356
if err != nil {
353357
cfg.Logger.Error("failed to initialize sync server", zap.Error(err))

pkg/sync/sync_worker.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,13 @@ func (s *syncWorker) start() error {
7979
return err
8080
}
8181

82+
if s.migration.Enable {
83+
s.logger.Info(
84+
"Migration client is enabled. Will migrate from migration originator",
85+
utils.OriginatorIDField(s.migration.FromNodeID),
86+
)
87+
}
88+
8289
for _, node := range nodes {
8390
s.subscribeToNode(node.NodeID)
8491
}
@@ -362,6 +369,13 @@ func (s *syncWorker) setupStream(
362369
migrator.WelcomeMessageOriginatorID,
363370
migrator.KeyPackagesOriginatorID,
364371
}
372+
if s.logger.Core().Enabled(zap.DebugLevel) {
373+
s.logger.Debug(
374+
"requesting additional migrated payloads from originator node",
375+
utils.OriginatorIDField(s.migration.FromNodeID),
376+
zap.Any("originators", originatorNodeIDs),
377+
)
378+
}
365379
}
366380

367381
stream, err := client.SubscribeEnvelopes(

0 commit comments

Comments
 (0)