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