Skip to content

Commit

Permalink
debug
Browse files Browse the repository at this point in the history
  • Loading branch information
jh-bate committed Dec 11, 2023
1 parent 1ff02a9 commit 9ddac0f
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ func (m *Migration) execute() error {
for m.fetchAndUpdateBatch() {
updatedCount, err := m.writeBatchUpdates()
if err != nil {
log.Printf("failed writing batch %s", err)
log.Printf("failed writing batch: %s", err)
return err
}
totalMigrated = totalMigrated + updatedCount
Expand Down Expand Up @@ -315,10 +315,9 @@ func (m *Migration) getWaitTime() (float64, error) {

var metaData MongoMetaData
m.client.Database("admin").RunCommand(m.ctx, bson.M{"replSetGetStatus": 1}).Decode(&metaData)
log.Println("DB replication status loaded.")
log.Printf("DB replication status loaded. %#v", metaData)

for _, member := range metaData.Members {
log.Printf("member %#v ", member)
if member.State < 1 || member.State > 2 || member.Health != 1 || member.Uptime < 120 {
log.Printf("DB member %s down or not ready.", member.Name)
return 240, nil
Expand Down Expand Up @@ -427,21 +426,22 @@ func (m *Migration) writeBatchUpdates() (int, error) {
batches := [][]mongo.WriteModel{}
for i := 0; i < len(m.updates); i += chunkSize {
end := i + chunkSize

if end > len(m.updates) {
end = len(m.updates)
}
batches = append(batches, m.updates[i:end])
}
return batches
}

updateCount := 0
log.Printf("write batch size %d", *m.writeBatchSize)
for _, batch := range getBatches(int(*m.writeBatchSize)) {
if err := m.blockUntilDBReady(); err != nil {
log.Printf("writeBatchUpdates-blocking error: %s", err)
return updateCount, err
}
if err := m.checkFreeSpace(); err != nil {
log.Printf("writeBatchUpdates-freespace error: %s", err)
return updateCount, err
}
log.Printf("updates to write %d", len(batch))
Expand Down

0 comments on commit 9ddac0f

Please sign in to comment.