refactor: enhance logging and batch processing in migration; adjust configuration parameters for improved performance
This commit is contained in:
@@ -129,7 +129,7 @@ func processMigrationJob(
|
||||
}()
|
||||
|
||||
maxExtractors := min(job.MaxExtractors, len(partitions))
|
||||
log.Infof("Starting %d extractor(s)...", maxExtractors)
|
||||
log.Infof("Starting %d extractor(s)... (%v)", maxExtractors, job.Name)
|
||||
|
||||
for range maxExtractors {
|
||||
wgExtractors.Go(func() {
|
||||
@@ -157,7 +157,7 @@ func processMigrationJob(
|
||||
}
|
||||
}()
|
||||
|
||||
log.Infof("Starting %d transformer(s)...", maxExtractors)
|
||||
log.Infof("Starting %d transformer(s)... (%v)", maxExtractors, job.Name)
|
||||
|
||||
for range maxExtractors {
|
||||
wgTransformers.Go(func() {
|
||||
@@ -165,6 +165,7 @@ func processMigrationJob(
|
||||
localCtx,
|
||||
sourceColTypes,
|
||||
job.Retry,
|
||||
job.TransformerBatchSize,
|
||||
chBatchesRaw,
|
||||
chBatchesTransformed,
|
||||
chJobErrors,
|
||||
@@ -173,7 +174,7 @@ func processMigrationJob(
|
||||
})
|
||||
}
|
||||
|
||||
log.Infof("Starting %d loader(s)...", job.MaxLoaders)
|
||||
log.Infof("Starting %d loader(s)... (%v)", job.MaxLoaders, job.Name)
|
||||
|
||||
for range job.MaxLoaders {
|
||||
wgLoaders.Go(func() {
|
||||
@@ -182,6 +183,7 @@ func processMigrationJob(
|
||||
job.TargetTable,
|
||||
targetColTypes,
|
||||
job.Retry,
|
||||
job.LoaderBatchSize,
|
||||
chBatchesTransformed,
|
||||
chJobErrors,
|
||||
&wgActiveBatches,
|
||||
@@ -192,28 +194,28 @@ func processMigrationJob(
|
||||
}
|
||||
|
||||
go func() {
|
||||
log.Debugf("Waiting for goroutines (%v)", job.Name)
|
||||
// log.Debugf("Waiting for goroutines (%v)", job.Name)
|
||||
|
||||
wgActivePartitions.Wait()
|
||||
log.Debugf("wgActivePartitions is empty (%v)", job.Name)
|
||||
// log.Debugf("wgActivePartitions is empty (%v)", job.Name)
|
||||
close(chPartitions)
|
||||
log.Debugf("chPartitions is closed (%v)", job.Name)
|
||||
// log.Debugf("chPartitions is closed (%v)", job.Name)
|
||||
|
||||
wgExtractors.Wait()
|
||||
log.Debugf("wgExtractors is empty (%v)", job.Name)
|
||||
// log.Debugf("wgExtractors is empty (%v)", job.Name)
|
||||
close(chBatchesRaw)
|
||||
log.Debugf("chBatchesRaw is closed (%v)", job.Name)
|
||||
// log.Debugf("chBatchesRaw is closed (%v)", job.Name)
|
||||
|
||||
wgTransformers.Wait()
|
||||
log.Debugf("wgTransformers is empty (%v)", job.Name)
|
||||
// log.Debugf("wgTransformers is empty (%v)", job.Name)
|
||||
close(chBatchesTransformed)
|
||||
// log.Debugf("chBatchesTransformed is closed (%v)", job.Name)
|
||||
|
||||
wgActiveBatches.Wait()
|
||||
log.Debugf("wgActiveBatches is empty (%v)", job.Name)
|
||||
close(chBatchesTransformed)
|
||||
log.Debugf("chBatchesTransformed is empty (%v)", job.Name)
|
||||
// log.Debugf("wgActiveBatches is empty (%v)", job.Name)
|
||||
|
||||
wgLoaders.Wait()
|
||||
log.Debugf("wgLoaders is empty (%v)", job.Name)
|
||||
// log.Debugf("wgLoaders is empty (%v)", job.Name)
|
||||
|
||||
cancel()
|
||||
}()
|
||||
@@ -225,9 +227,9 @@ func processMigrationJob(
|
||||
}
|
||||
}
|
||||
|
||||
log.Debugf("waiting for local context to be done (%v)", job.Name)
|
||||
// log.Debugf("waiting for local context to be done (%v)", job.Name)
|
||||
<-localCtx.Done()
|
||||
log.Debugf("local context done (%v)", job.Name)
|
||||
// log.Debugf("local context done (%v)", job.Name)
|
||||
|
||||
if ctx.Err() != nil {
|
||||
result.Error = ctx.Err()
|
||||
@@ -242,5 +244,9 @@ func processMigrationJob(
|
||||
result.Error = fmt.Errorf("Row count mismatch: extracted %d rows but loaded %d rows (failed: %d)", result.RowsRead, result.RowsLoaded, result.RowsFailed)
|
||||
}
|
||||
|
||||
if result.RowsRead == 0 {
|
||||
log.Warnf("No rows extracted from (%v)", job.Name)
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user