zhannngchen commented on code in PR #26210:
URL: https://github.com/apache/doris/pull/26210#discussion_r1380025843
##########
fe/fe-core/src/main/java/org/apache/doris/transaction/DatabaseTransactionMgr.java:
##########
@@ -674,6 +674,33 @@ public void commitTransaction(List<Table> tableList, long
transactionId, List<Ta
+ "] is prepare, not pre-committed.");
}
+ if (transactionState.isPartialUpdate()) {
+ if (is2PC) {
+ Iterator<TableCommitInfo> tableCommitInfoIterator
+ =
transactionState.getIdToTableCommitInfos().values().iterator();
+ while (tableCommitInfoIterator.hasNext()) {
+ TableCommitInfo tableCommitInfo =
tableCommitInfoIterator.next();
+ long tableId = tableCommitInfo.getTableId();
+ OlapTable table = (OlapTable) db.getTableNullable(tableId);
+ if (table != null && table instanceof OlapTable) {
+ if
(!transactionState.checkSchemaCompatibility((OlapTable) table)) {
+ throw new
TransactionCommitFailedException("transaction [" + transactionId
+ + "] check schema compatibility failed");
Review Comment:
check schema compatibility failed, partial update with old schema can't
sommit sucessfully.
##########
fe/fe-core/src/main/java/org/apache/doris/transaction/TransactionState.java:
##########
@@ -725,4 +747,45 @@ public void clearErrorMsg() {
public String getErrMsg() {
return this.errMsg;
}
+
+ public void setSchemaForPartialUpdate(OlapTable olapTable) {
+ // the caller should hold the read lock of the table
+ isPartialUpdate = true;
+ txnSchemas.put(olapTable.getId(), new SchemaInfo(olapTable));
+ }
+
+ public boolean isPartialUpdate() {
+ return isPartialUpdate;
+ }
+
+ public SchemaInfo getTxnSchema(long id) {
+ return txnSchemas.get(id);
+ }
+
+ public boolean checkSchemaCompatibility(OlapTable olapTable) {
+ SchemaInfo currentSchemaInfo = new SchemaInfo(olapTable);
+ SchemaInfo txnSchemaInfo = txnSchemas.get(olapTable.getId());
+ if (txnSchemaInfo == null) {
+ return true;
+ }
+ if (txnSchemaInfo.schemaVersion >= currentSchemaInfo.schemaVersion) {
+ return true;
+ }
+ for (Column txnCol : txnSchemaInfo.schema) {
+ if (!txnCol.isVisible() || !txnCol.getType().isStringType()) {
+ continue;
+ }
+ int uniqueId = txnCol.getUniqueId();
+ Optional<Column> currentCol = currentSchemaInfo.schema.stream()
+ .filter(col -> col.getUniqueId() == uniqueId).findFirst();
+ if (currentCol.isPresent() &&
currentCol.get().getType().isStringType()) {
+ if (currentCol.get().getStrLen() != txnCol.getStrLen()) {
Review Comment:
Add a comment: for now Doris's light schema change only supports adding
columns, dropping columns, and type conversions that increase the varchar length
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]