@@ -775,6 +775,57 @@ func TestMigratorRetryWithExponentialBackoffAbortsOnContextCancellation(t *testi
775775 assert .Contains (t , result .Error (), "context canceled" )
776776}
777777
778+ func TestMigratorRetrySkipsRetriesForWarnings (t * testing.T ) {
779+ oldRetrySleepFn := RetrySleepFn
780+ defer func () { RetrySleepFn = oldRetrySleepFn }()
781+
782+ migrationContext := base .NewMigrationContext ()
783+ migrationContext .SetDefaultNumRetries (100 )
784+ migrator := NewMigrator (migrationContext , "1.2.3" )
785+
786+ RetrySleepFn = func (duration time.Duration ) {
787+ t .Fatal ("Should not sleep/retry for warning errors" )
788+ }
789+
790+ var tries = 0
791+ retryable := func () error {
792+ tries ++
793+ return errors .New ("warnings detected in statement 1 of 1: [Warning: Duplicate entry 'test' for key 'idx' (1062)]" )
794+ }
795+
796+ result := migrator .retryOperation (retryable , false )
797+ assert .Error (t , result )
798+ // Should only try once - no retries for warnings
799+ assert .Equal (t , 1 , tries , "Expected exactly 1 try (no retries) for warning error" )
800+ assert .Contains (t , result .Error (), "warnings detected" )
801+ }
802+
803+ func TestMigratorRetryWithExponentialBackoffSkipsRetriesForWarnings (t * testing.T ) {
804+ oldRetrySleepFn := RetrySleepFn
805+ defer func () { RetrySleepFn = oldRetrySleepFn }()
806+
807+ migrationContext := base .NewMigrationContext ()
808+ migrationContext .SetDefaultNumRetries (100 )
809+ migrationContext .SetExponentialBackoffMaxInterval (42 )
810+ migrator := NewMigrator (migrationContext , "1.2.3" )
811+
812+ RetrySleepFn = func (duration time.Duration ) {
813+ t .Fatal ("Should not sleep/retry for warning errors" )
814+ }
815+
816+ var tries = 0
817+ retryable := func () error {
818+ tries ++
819+ return errors .New ("warnings detected in statement 1 of 1: [Warning: Duplicate entry 'test' for key 'idx' (1062)]" )
820+ }
821+
822+ result := migrator .retryOperationWithExponentialBackoff (retryable , false )
823+ assert .Error (t , result )
824+ // Should only try once - no retries for warnings
825+ assert .Equal (t , 1 , tries , "Expected exactly 1 try (no retries) for warning error" )
826+ assert .Contains (t , result .Error (), "warnings detected" )
827+ }
828+
778829func (suite * MigratorTestSuite ) TestCutOverLossDataCaseLockGhostBeforeRename () {
779830 ctx := context .Background ()
780831
0 commit comments