Skip to content

Commit a9ae023

Browse files
committed
KYLIN-5388 Fix mvcc error
1 parent dee005e commit a9ae023

File tree

3 files changed

+17
-10
lines changed

3 files changed

+17
-10
lines changed

src/common-service/src/main/java/org/apache/kylin/rest/service/update/TableSchemaUpdater.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public static TableDesc dealWithMappingForTable(TableDesc other, Map<String, Tab
4545
return other;
4646
}
4747

48-
TableDesc copy = new TableDesc(other);
48+
TableDesc copy = new TableDesc(other, false);
4949

5050
copy.setDatabase(mapping.getDatabase(other.getDatabase()));
5151
copy.setName(mapping.getTableName(other.getName()));

src/core-metadata/src/main/java/org/apache/kylin/metadata/model/TableDesc.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,10 @@ public TableDesc() {
203203
}
204204

205205
public TableDesc(TableDesc other) {
206+
this(other, true);
207+
}
208+
209+
public TableDesc(TableDesc other, boolean copyMvcc) {
206210
this.uuid = other.uuid;
207211
this.lastModified = other.lastModified;
208212
this.createTime = other.createTime;
@@ -234,7 +238,9 @@ public TableDesc(TableDesc other) {
234238
this.isTransactional = other.isTransactional;
235239
this.isRangePartition = other.isRangePartition;
236240
this.partitionDesc = other.partitionDesc;
237-
setMvcc(other.getMvcc());
241+
if (copyMvcc) {
242+
setMvcc(other.getMvcc());
243+
}
238244
}
239245

240246
/**

src/datasource-service/src/main/java/org/apache/kylin/rest/service/TableService.java

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2099,7 +2099,7 @@ public void updateHiveTable(String projectName, Map<String, TableSchemaUpdateMap
20992099
if (prjInstance == null) {
21002100
throw new BadRequestException("Project " + projectName + " does not exist");
21012101
}
2102-
// To deal with case sensitive issue for table resource path
2102+
// To deal with case-sensitive issue for table resource path
21032103
final String project = prjInstance.getName();
21042104
aclEvaluate.checkProjectWritePermission(project);
21052105

@@ -2118,15 +2118,16 @@ public void updateHiveTable(String projectName, Map<String, TableSchemaUpdateMap
21182118
ifAllModelUpdate = nModel == infModels.size();
21192119
}
21202120
// Currently, only model with offline status is supported to update with mappings.
2121-
Set<NDataModel> readyModelSet = infModels.stream().filter(model -> NDataflowManager.getInstance(kylinConfig, project)
2121+
Set<NDataModel> offlineModelSet = infModels.stream().filter(model -> NDataflowManager.getInstance(kylinConfig, project)
21222122
.getDataflowByModelAlias(model.getAlias()).getStatus() == RealizationStatusEnum.OFFLINE)
21232123
.collect(Collectors.toSet());
2124-
ifAllModelUpdate = (ifAllModelUpdate && readyModelSet.size() == infModels.size());
2124+
ifAllModelUpdate = (ifAllModelUpdate && offlineModelSet.size() == infModels.size());
21252125
// At least 1 model should be update here, otherwise it will throw BadRequestException.
2126-
if (readyModelSet.isEmpty()) {
2127-
throw new BadRequestException("Influenced models " + infModels + " should be OFFLINE");
2126+
if (offlineModelSet.isEmpty()) {
2127+
throw new BadRequestException("Affected models " + infModels + " should be OFFLINE");
21282128
}
2129-
logger.info("Influenced cubes {}", readyModelSet);
2129+
logger.info("Should affected models {}", infModels);
2130+
logger.info("Actually affected offline models {}", offlineModelSet);
21302131

21312132
// Get influenced metadata and update the metadata
21322133
NTableMetadataManager tableManager = NTableMetadataManager.getInstance(kylinConfig, project);
@@ -2145,11 +2146,11 @@ public void updateHiveTable(String projectName, Map<String, TableSchemaUpdateMap
21452146
}
21462147
}
21472148
// -- 2. model
2148-
Map<String, NDataModel> newModels = readyModelSet.stream().map(model -> TableSchemaUpdater
2149+
Map<String, NDataModel> newModels = offlineModelSet.stream().map(model -> TableSchemaUpdater
21492150
.dealWithMappingForModel(kylinConfig, project, model, mapping))
21502151
.collect(Collectors.toMap(NDataModel::getAlias, model -> model));
21512152
// -- 3. dataflow
2152-
Map<String, NDataflow> newDataflow = readyModelSet.stream()
2153+
Map<String, NDataflow> newDataflow = offlineModelSet.stream()
21532154
.map(model -> NDataflowManager.getInstance(kylinConfig, project).getDataflowByModelAlias(model.getAlias()))
21542155
.map(dataflow -> TableSchemaUpdater.dealWithMappingForDataFlow(kylinConfig, project, dataflow, mapping))
21552156
.collect(Collectors.toMap(NDataflow::resourceName, dataflow -> dataflow));

0 commit comments

Comments
 (0)