@@ -2028,3 +2028,60 @@ func TestRegionJobResetRetryCounter(t *testing.T) {
2028
2028
}
2029
2029
}
2030
2030
}
2031
+
2032
+ func TestCtxCancelIsIgnored (t * testing.T ) {
2033
+ backup := maxRetryBackoffSecond
2034
+ maxRetryBackoffSecond = 1
2035
+ t .Cleanup (func () {
2036
+ maxRetryBackoffSecond = backup
2037
+ })
2038
+
2039
+ _ = failpoint .Enable ("github.com/pingcap/tidb/br/pkg/lightning/backend/local/skipSplitAndScatter" , "return()" )
2040
+ _ = failpoint .Enable ("github.com/pingcap/tidb/br/pkg/lightning/backend/local/fakeRegionJobs" , "return()" )
2041
+ _ = failpoint .Enable ("github.com/pingcap/tidb/br/pkg/lightning/backend/local/beforeGenerateJob" , "sleep(1000)" )
2042
+ _ = failpoint .Enable ("github.com/pingcap/tidb/br/pkg/lightning/backend/local/WriteToTiKVNotEnoughDiskSpace" , "return()" )
2043
+ t .Cleanup (func () {
2044
+ _ = failpoint .Disable ("github.com/pingcap/tidb/br/pkg/lightning/backend/local/skipSplitAndScatter" )
2045
+ _ = failpoint .Disable ("github.com/pingcap/tidb/br/pkg/lightning/backend/local/fakeRegionJobs" )
2046
+ _ = failpoint .Disable ("github.com/pingcap/tidb/br/pkg/lightning/backend/local/beforeGenerateJob" )
2047
+ _ = failpoint .Disable ("github.com/pingcap/tidb/br/pkg/lightning/backend/local/WriteToTiKVNotEnoughDiskSpace" )
2048
+ })
2049
+
2050
+ initRanges := []Range {
2051
+ {start : []byte {'c' }, end : []byte {'d' }},
2052
+ {start : []byte {'d' }, end : []byte {'e' }},
2053
+ }
2054
+ fakeRegionJobs = map [[2 ]string ]struct {
2055
+ jobs []* regionJob
2056
+ err error
2057
+ }{
2058
+ {"c" , "d" }: {
2059
+ jobs : []* regionJob {
2060
+ {
2061
+ keyRange : Range {start : []byte {'c' }, end : []byte {'d' }},
2062
+ engine : & Engine {},
2063
+ injected : getSuccessInjectedBehaviour (),
2064
+ },
2065
+ },
2066
+ },
2067
+ {"d" , "e" }: {
2068
+ jobs : []* regionJob {
2069
+ {
2070
+ keyRange : Range {start : []byte {'d' }, end : []byte {'e' }},
2071
+ engine : & Engine {},
2072
+ injected : getSuccessInjectedBehaviour (),
2073
+ },
2074
+ },
2075
+ },
2076
+ }
2077
+
2078
+ ctx := context .Background ()
2079
+ l := & Backend {
2080
+ BackendConfig : BackendConfig {
2081
+ WorkerConcurrency : 1 ,
2082
+ },
2083
+ }
2084
+ e := & Engine {}
2085
+ err := l .doImport (ctx , e , initRanges , int64 (config .SplitRegionSize ), int64 (config .SplitRegionKeys ))
2086
+ require .ErrorContains (t , err , "the remaining storage capacity of TiKV" )
2087
+ }
0 commit comments