|
19 | 19 | import java.util.Collection; |
20 | 20 | import java.util.Collections; |
21 | 21 | import java.util.List; |
| 22 | +import java.util.Optional; |
22 | 23 | import java.util.function.Predicate; |
23 | 24 | import java.util.stream.Collectors; |
24 | 25 |
|
|
27 | 28 | import org.slf4j.Logger; |
28 | 29 | import org.slf4j.LoggerFactory; |
29 | 30 |
|
| 31 | +import com.oceanbase.odc.common.util.ExceptionUtils; |
30 | 32 | import com.oceanbase.odc.core.shared.Verify; |
31 | 33 | import com.oceanbase.odc.core.shared.constant.TaskStatus; |
32 | 34 | import com.oceanbase.odc.plugin.task.api.datatransfer.DataTransferJob; |
33 | 35 | import com.oceanbase.odc.plugin.task.api.datatransfer.model.DataTransferTaskResult; |
34 | 36 | import com.oceanbase.odc.plugin.task.api.datatransfer.model.ObjectResult; |
35 | 37 | import com.oceanbase.tools.loaddump.common.enums.DataFormat; |
36 | 38 | import com.oceanbase.tools.loaddump.common.enums.ObjectType; |
| 39 | +import com.oceanbase.tools.loaddump.common.enums.ServerMode; |
37 | 40 | import com.oceanbase.tools.loaddump.common.model.BaseParameter; |
38 | 41 | import com.oceanbase.tools.loaddump.common.model.DumpParameter; |
39 | 42 | import com.oceanbase.tools.loaddump.common.model.LoadParameter; |
@@ -175,7 +178,12 @@ public DataTransferTaskResult call() throws Exception { |
175 | 178 | if (dataContext != null) { |
176 | 179 | dataContext.shutdownNow(); |
177 | 180 | } |
178 | | - throw e; |
| 181 | + String rootMessage = Optional.ofNullable(ExceptionUtils.getRootCause(e)).orElseThrow(() -> e).getMessage(); |
| 182 | + if (shouldEatException(rootMessage)) { |
| 183 | + LOGGER.warn(rootMessage); |
| 184 | + } else { |
| 185 | + throw e; |
| 186 | + } |
179 | 187 | } |
180 | 188 |
|
181 | 189 | validAllTasksSuccessed(); |
@@ -242,6 +250,35 @@ private void syncWaitFinished(@NonNull TaskContext context, boolean isTransferSc |
242 | 250 | throw new InterruptedException("loop interrupted"); |
243 | 251 | } |
244 | 252 |
|
| 253 | + /** |
| 254 | + * @return a bool value. If it's true, the exception should be eaten. |
| 255 | + */ |
| 256 | + private boolean shouldEatException(String errorMessage) { |
| 257 | + if (StringUtils.isEmpty(errorMessage)) { |
| 258 | + return false; |
| 259 | + } |
| 260 | + if (errorMessage.contains("No subfiles are generated from path")) { |
| 261 | + return true; |
| 262 | + } |
| 263 | + if (errorMessage.contains("table or view does not exist")) { |
| 264 | + ServerMode serverMode = parameter.getConnectionKey().getServerMode(); |
| 265 | + if (serverMode.isMysqlMode()) { |
| 266 | + LOGGER.warn( |
| 267 | + "The current user may lack access to the oceanbase database. " |
| 268 | + + "You can execute the following SQL and retry the transfer task:\n" |
| 269 | + + "grant select on oceanbase.* to {}", |
| 270 | + parameter.getUser()); |
| 271 | + } else { |
| 272 | + LOGGER.warn( |
| 273 | + "The current user may lack of DBA permission. " |
| 274 | + + "You can execute the following SQL and retry the transfer task:\n" |
| 275 | + + "grant select any dictionary to {}", |
| 276 | + parameter.getUser()); |
| 277 | + } |
| 278 | + } |
| 279 | + return false; |
| 280 | + } |
| 281 | + |
245 | 282 | private void shutdownContext(TaskContext context) { |
246 | 283 | try { |
247 | 284 | context.shutdown(); |
|
0 commit comments