@@ -438,15 +438,15 @@ func (this *Applier) ExecuteThrottleQuery() (int64, error) {
438
438
return result , nil
439
439
}
440
440
441
- // ReadMigrationMinValues returns the minimum values to be iterated on rowcopy
442
- func (this * Applier ) ReadMigrationMinValues ( uniqueKey * sql.UniqueKey ) error {
441
+ // readMigrationMinValues returns the minimum values to be iterated on rowcopy
442
+ func (this * Applier ) readMigrationMinValues ( tx * gosql. Tx , uniqueKey * sql.UniqueKey ) error {
443
443
this .migrationContext .Log .Debugf ("Reading migration range according to key: %s" , uniqueKey .Name )
444
444
query , err := sql .BuildUniqueKeyMinValuesPreparedQuery (this .migrationContext .DatabaseName , this .migrationContext .OriginalTableName , & uniqueKey .Columns )
445
445
if err != nil {
446
446
return err
447
447
}
448
448
449
- rows , err := this . db .Query (query )
449
+ rows , err := tx .Query (query )
450
450
if err != nil {
451
451
return err
452
452
}
@@ -463,15 +463,15 @@ func (this *Applier) ReadMigrationMinValues(uniqueKey *sql.UniqueKey) error {
463
463
return rows .Err ()
464
464
}
465
465
466
- // ReadMigrationMaxValues returns the maximum values to be iterated on rowcopy
467
- func (this * Applier ) ReadMigrationMaxValues ( uniqueKey * sql.UniqueKey ) error {
466
+ // readMigrationMaxValues returns the maximum values to be iterated on rowcopy
467
+ func (this * Applier ) readMigrationMaxValues ( tx * gosql. Tx , uniqueKey * sql.UniqueKey ) error {
468
468
this .migrationContext .Log .Debugf ("Reading migration range according to key: %s" , uniqueKey .Name )
469
469
query , err := sql .BuildUniqueKeyMaxValuesPreparedQuery (this .migrationContext .DatabaseName , this .migrationContext .OriginalTableName , & uniqueKey .Columns )
470
470
if err != nil {
471
471
return err
472
472
}
473
473
474
- rows , err := this . db .Query (query )
474
+ rows , err := tx .Query (query )
475
475
if err != nil {
476
476
return err
477
477
}
@@ -510,13 +510,20 @@ func (this *Applier) ReadMigrationRangeValues() error {
510
510
return err
511
511
}
512
512
513
- if err := this .ReadMigrationMinValues (this .migrationContext .UniqueKey ); err != nil {
513
+ tx , err := this .db .Begin ()
514
+ if err != nil {
514
515
return err
515
516
}
516
- if err := this .ReadMigrationMaxValues (this .migrationContext .UniqueKey ); err != nil {
517
+ defer tx .Rollback ()
518
+
519
+ if err := this .readMigrationMinValues (tx , this .migrationContext .UniqueKey ); err != nil {
517
520
return err
518
521
}
519
- return nil
522
+ if err := this .readMigrationMaxValues (tx , this .migrationContext .UniqueKey ); err != nil {
523
+ return err
524
+ }
525
+
526
+ return tx .Commit ()
520
527
}
521
528
522
529
// CalculateNextIterationRangeEndValues reads the next-iteration-range-end unique key values,
0 commit comments