|
18 | 18 | import com.google.common.collect.Maps; |
19 | 19 | import com.starrocks.common.Reference; |
20 | 20 | import com.starrocks.common.StarRocksException; |
| 21 | +import com.starrocks.connector.exception.GlobalDictNotMatchException; |
21 | 22 | import com.starrocks.proto.PCancelPlanFragmentRequest; |
22 | 23 | import com.starrocks.proto.PCancelPlanFragmentResult; |
23 | 24 | import com.starrocks.proto.PExecPlanFragmentResult; |
|
54 | 55 | import java.util.concurrent.TimeUnit; |
55 | 56 | import java.util.concurrent.TimeoutException; |
56 | 57 | import java.util.concurrent.atomic.AtomicBoolean; |
| 58 | +import java.util.concurrent.atomic.AtomicInteger; |
57 | 59 |
|
58 | 60 | import static com.starrocks.utframe.MockedBackend.MockPBackendService; |
59 | 61 | import static org.assertj.core.api.Assertions.assertThat; |
@@ -212,6 +214,57 @@ public Future<PExecPlanFragmentResult> execPlanFragmentAsync(PExecPlanFragmentRe |
212 | 214 | Assert.assertTrue(scheduler.isDone()); |
213 | 215 | } |
214 | 216 |
|
| 217 | + @Test |
| 218 | + public void testDeployFutureThrowRetryableException() throws Exception { |
| 219 | + AtomicInteger numDeployedFragments = new AtomicInteger(0); |
| 220 | + |
| 221 | + setBackendService(address -> { |
| 222 | + |
| 223 | + final int numFragments = numDeployedFragments.incrementAndGet(); |
| 224 | + if (numFragments == 1) { |
| 225 | + return new MockPBackendService(); |
| 226 | + } |
| 227 | + |
| 228 | + if (numFragments == 2) { |
| 229 | + return new MockPBackendService() { |
| 230 | + @Override |
| 231 | + public Future<PExecPlanFragmentResult> execPlanFragmentAsync(PExecPlanFragmentRequest request) { |
| 232 | + return submit(() -> { |
| 233 | + PExecPlanFragmentResult result = new PExecPlanFragmentResult(); |
| 234 | + StatusPB pStatus = new StatusPB(); |
| 235 | + pStatus.statusCode = TStatusCode.CANCELLED.getValue(); |
| 236 | + pStatus.errorMsgs = Collections.singletonList("test CANCELLED error message"); |
| 237 | + result.status = pStatus; |
| 238 | + return result; |
| 239 | + }); |
| 240 | + } |
| 241 | + }; |
| 242 | + } |
| 243 | + |
| 244 | + if (numFragments == 3) { |
| 245 | + return new MockPBackendService() { |
| 246 | + @Override |
| 247 | + public Future<PExecPlanFragmentResult> execPlanFragmentAsync(PExecPlanFragmentRequest request) { |
| 248 | + return submit(() -> { |
| 249 | + PExecPlanFragmentResult result = new PExecPlanFragmentResult(); |
| 250 | + StatusPB pStatus = new StatusPB(); |
| 251 | + pStatus.statusCode = TStatusCode.GLOBAL_DICT_NOT_MATCH.getValue(); |
| 252 | + pStatus.errorMsgs = Collections.singletonList("test GLOBAL_DICT_NOT_MATCH error message"); |
| 253 | + result.status = pStatus; |
| 254 | + return result; |
| 255 | + }); |
| 256 | + } |
| 257 | + }; |
| 258 | + } |
| 259 | + |
| 260 | + return new MockPBackendService(); |
| 261 | + }); |
| 262 | + String sql = |
| 263 | + "select count(1) from lineitem UNION ALL select count(1) from lineitem UNION ALL select count(1) from lineitem"; |
| 264 | + DefaultCoordinator scheduler = getScheduler(sql); |
| 265 | + Assert.assertThrows(GlobalDictNotMatchException.class, scheduler::exec); |
| 266 | + } |
| 267 | + |
215 | 268 | @Test |
216 | 269 | public void testDeployFutureReturnErrorStatus() throws Exception { |
217 | 270 | final int successDeployedFragmentCount = 3; |
|
0 commit comments