This is an automated email from the ASF dual-hosted git repository. yiguolei pushed a commit to branch branch-2.1 in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-2.1 by this push: new 92db3076977 branch-2.1: [fix](edit_log) throw exception when replay alter constraint on catalog table #47151 (#47233) 92db3076977 is described below commit 92db307697762df22c815b979bc24ad808f30319 Author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> AuthorDate: Sat Jan 25 08:32:01 2025 +0800 branch-2.1: [fix](edit_log) throw exception when replay alter constraint on catalog table #47151 (#47233) Cherry-picked from #47151 Co-authored-by: morrySnow <zhangwen...@selectdb.com> --- .../java/org/apache/doris/catalog/TableIf.java | 39 +++++++++------------- .../java/org/apache/doris/persist/EditLog.java | 12 +++++-- 2 files changed, 25 insertions(+), 26 deletions(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/catalog/TableIf.java b/fe/fe-core/src/main/java/org/apache/doris/catalog/TableIf.java index 2efb310657a..917314d3823 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/catalog/TableIf.java +++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/TableIf.java @@ -318,34 +318,25 @@ public interface TableIf { } default void replayAddConstraint(Constraint constraint) { - // Since constraints are not indispensable, we only log when replay fails - try { - if (constraint instanceof UniqueConstraint) { - UniqueConstraint uniqueConstraint = (UniqueConstraint) constraint; - this.addUniqueConstraint(constraint.getName(), - ImmutableList.copyOf(uniqueConstraint.getUniqueColumnNames()), true); - } else if (constraint instanceof PrimaryKeyConstraint) { - PrimaryKeyConstraint primaryKeyConstraint = (PrimaryKeyConstraint) constraint; - this.addPrimaryKeyConstraint(primaryKeyConstraint.getName(), - ImmutableList.copyOf(primaryKeyConstraint.getPrimaryKeyNames()), true); - } else if (constraint instanceof ForeignKeyConstraint) { - ForeignKeyConstraint foreignKey = (ForeignKeyConstraint) constraint; - this.addForeignConstraint(foreignKey.getName(), - ImmutableList.copyOf(foreignKey.getForeignKeyNames()), - foreignKey.getReferencedTable(), - ImmutableList.copyOf(foreignKey.getReferencedColumnNames()), true); - } - } catch (Exception e) { - LOG.error(e.getMessage()); + if (constraint instanceof UniqueConstraint) { + UniqueConstraint uniqueConstraint = (UniqueConstraint) constraint; + this.addUniqueConstraint(constraint.getName(), + ImmutableList.copyOf(uniqueConstraint.getUniqueColumnNames()), true); + } else if (constraint instanceof PrimaryKeyConstraint) { + PrimaryKeyConstraint primaryKeyConstraint = (PrimaryKeyConstraint) constraint; + this.addPrimaryKeyConstraint(primaryKeyConstraint.getName(), + ImmutableList.copyOf(primaryKeyConstraint.getPrimaryKeyNames()), true); + } else if (constraint instanceof ForeignKeyConstraint) { + ForeignKeyConstraint foreignKey = (ForeignKeyConstraint) constraint; + this.addForeignConstraint(foreignKey.getName(), + ImmutableList.copyOf(foreignKey.getForeignKeyNames()), + foreignKey.getReferencedTable(), + ImmutableList.copyOf(foreignKey.getReferencedColumnNames()), true); } } default void replayDropConstraint(String name) { - try { - dropConstraint(name, true); - } catch (Exception e) { - LOG.error(e.getMessage()); - } + dropConstraint(name, true); } default void dropConstraint(String name, boolean replay) { diff --git a/fe/fe-core/src/main/java/org/apache/doris/persist/EditLog.java b/fe/fe-core/src/main/java/org/apache/doris/persist/EditLog.java index 9d760195b8a..6f2068625bb 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/persist/EditLog.java +++ b/fe/fe-core/src/main/java/org/apache/doris/persist/EditLog.java @@ -1016,12 +1016,20 @@ public class EditLog { } case OperationType.OP_ADD_CONSTRAINT: { final AlterConstraintLog log = (AlterConstraintLog) journal.getData(); - log.getTableIf().replayAddConstraint(log.getConstraint()); + try { + log.getTableIf().replayAddConstraint(log.getConstraint()); + } catch (Exception e) { + LOG.error("Failed to replay add constraint", e); + } break; } case OperationType.OP_DROP_CONSTRAINT: { final AlterConstraintLog log = (AlterConstraintLog) journal.getData(); - log.getTableIf().replayDropConstraint(log.getConstraint().getName()); + try { + log.getTableIf().replayDropConstraint(log.getConstraint().getName()); + } catch (Exception e) { + LOG.error("Failed to replay drop constraint", e); + } break; } case OperationType.OP_ALTER_USER: { --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org