|
22 | 22 | import io.dingodb.common.log.LogUtils; |
23 | 23 | import io.dingodb.common.meta.Tenant; |
24 | 24 | import io.dingodb.common.mysql.scope.ScopeVariables; |
| 25 | +import io.dingodb.common.parser.CharTypes; |
25 | 26 | import io.dingodb.common.session.Session; |
26 | 27 | import io.dingodb.common.session.SessionUtil; |
27 | 28 | import io.dingodb.common.tenant.TenantConstant; |
|
41 | 42 | import io.dingodb.sdk.service.entity.coordinator.GetGCSafePointRequest; |
42 | 43 | import io.dingodb.sdk.service.entity.coordinator.GetGCSafePointResponse; |
43 | 44 | import io.dingodb.sdk.service.entity.coordinator.GetRegionMapRequest; |
| 45 | +import io.dingodb.sdk.service.entity.coordinator.ScanRegionInfo; |
44 | 46 | import io.dingodb.sdk.service.entity.coordinator.UpdateGCSafePointRequest; |
45 | 47 | import io.dingodb.sdk.service.entity.meta.DeleteAutoIncrementRequest; |
46 | 48 | import io.dingodb.sdk.service.entity.meta.DingoCommonId; |
@@ -849,20 +851,37 @@ private static void gcDeleteRange(long startTs) { |
849 | 851 | LogUtils.info(log, "gc schema meta, schemaId:{}", eleId); |
850 | 852 | return; |
851 | 853 | } |
| 854 | + |
852 | 855 | try { |
853 | | - coordinatorService.dropRegion( |
854 | | - tso(), |
855 | | - DropRegionRequest.builder().regionId(regionId).build() |
856 | | - ); |
857 | | - LogUtils.info(log, "gcDeleteRange success, regionId:{}", regionId); |
858 | | - long jobId = (long) objects[3]; |
859 | | - long ts = (long) objects[4]; |
860 | 856 | String startKey = objects[1].toString(); |
861 | 857 | String endKey = objects[2].toString(); |
| 858 | + List<Object> regionList = InfoSchemaService.root() |
| 859 | + .scanRegions(CharTypes.hexToBytes(startKey), CharTypes.hexToBytes(endKey)); |
| 860 | + if (regionList.size() > 1) { |
| 861 | + regionList |
| 862 | + .forEach(object -> { |
| 863 | + ScanRegionInfo scanRegionInfo = (ScanRegionInfo) object; |
| 864 | + coordinatorService.dropRegion( |
| 865 | + tso(), |
| 866 | + DropRegionRequest.builder().regionId(scanRegionInfo.getRegionId()).build() |
| 867 | + ); |
| 868 | + LogUtils.info(log, "multi region drop success, regionId:{}", |
| 869 | + scanRegionInfo.getRegionId()); |
| 870 | + }); |
| 871 | + } else { |
| 872 | + coordinatorService.dropRegion( |
| 873 | + tso(), |
| 874 | + DropRegionRequest.builder().regionId(regionId).build() |
| 875 | + ); |
| 876 | + LogUtils.info(log, "single region drop success, regionId:{}", regionId); |
| 877 | + } |
| 878 | + long jobId = (long) objects[3]; |
| 879 | + long ts = (long) objects[4]; |
862 | 880 | String eleId = (String) objects[5]; |
863 | 881 | dropTableMeta(eleId, jobId, session, eleType); |
864 | 882 | if (!gcDeleteDone(jobId, ts, regionId, startKey, endKey, eleId, eleType, true)) { |
865 | | - LogUtils.error(log, "remove gcDeleteTask failed, jobId:{}, eleId:{}, eleType:{}", jobId, eleId, eleType); |
| 883 | + LogUtils.error(log, "remove gcDeleteTask failed, jobId:{}, eleId:{}, eleType:{}", |
| 884 | + jobId, eleId, eleType); |
866 | 885 | } else { |
867 | 886 | delDone.incrementAndGet(); |
868 | 887 | } |
|
0 commit comments