From ff335cb469218a00f47b9f035b41d0aba9555522 Mon Sep 17 00:00:00 2001 From: xy720 Date: Thu, 17 Aug 2023 10:21:21 +0800 Subject: [PATCH 1/5] save code --- fe/fe-core/src/main/cup/sql_parser.cup | 4 + .../AdminSetPartitionVersionStmt.java | 79 +++++++++++++++++++ .../java/org/apache/doris/catalog/Env.java | 58 ++++++++++++++ .../doris/common/util/PropertyAnalyzer.java | 35 ++++++++ .../apache/doris/journal/JournalEntity.java | 6 ++ .../org/apache/doris/persist/EditLog.java | 9 +++ .../apache/doris/persist/OperationType.java | 1 + .../SetPartitionVersionOperationLog.java | 60 ++++++++++++++ .../java/org/apache/doris/qe/DdlExecutor.java | 3 + .../apache/doris/catalog/AdminStmtTest.java | 59 ++++++++++++++ 10 files changed, 314 insertions(+) create mode 100644 fe/fe-core/src/main/java/org/apache/doris/analysis/AdminSetPartitionVersionStmt.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/persist/SetPartitionVersionOperationLog.java diff --git a/fe/fe-core/src/main/cup/sql_parser.cup b/fe/fe-core/src/main/cup/sql_parser.cup index c4258b2330198f..3691bde1934e14 100644 --- a/fe/fe-core/src/main/cup/sql_parser.cup +++ b/fe/fe-core/src/main/cup/sql_parser.cup @@ -7216,6 +7216,10 @@ admin_stmt ::= {: RESULT = new AdminCleanTrashStmt(null); :} + | KW_ADMIN KW_SET KW_PARTITION KW_VERSION opt_properties:properties + {: + RESULT = new AdminSetPartitionVersionStmt(properties); + :} | KW_ADMIN KW_DIAGNOSE KW_TABLET INTEGER_LITERAL:tabletId {: RESULT = new AdminDiagnoseTabletStmt(tabletId); diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/AdminSetPartitionVersionStmt.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/AdminSetPartitionVersionStmt.java new file mode 100644 index 00000000000000..eaf53863ae9f66 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/AdminSetPartitionVersionStmt.java @@ -0,0 +1,79 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package org.apache.doris.analysis; + +import org.apache.doris.catalog.Env; +import org.apache.doris.common.AnalysisException; +import org.apache.doris.common.ErrorCode; +import org.apache.doris.common.ErrorReport; +import org.apache.doris.common.UserException; +import org.apache.doris.common.util.PropertyAnalyzer; +import org.apache.doris.mysql.privilege.PrivPredicate; +import org.apache.doris.qe.ConnectContext; + +import java.util.Map; + +// Modify version of specified partition. Only used in emergency. +/* + * admin set partition version properties ("key" = "val", ..); + * "partition_id" = "20010", + * "visible_version" = "101" + */ +public class AdminSetPartitionVersionStmt extends DdlStmt { + private long partitionId = -1; + private long visibleVersion = -1; + private final Map properties; + + public AdminSetPartitionVersionStmt(Map properties) { + this.properties = properties; + } + + public Long getPartitionId() { + return partitionId; + } + + public Long getVisibleVersion() { + return visibleVersion; + } + + @Override + public void analyze(Analyzer analyzer) throws AnalysisException, UserException { + super.analyze(analyzer); + + // check auth + if (!Env.getCurrentEnv().getAccessManager().checkGlobalPriv(ConnectContext.get(), PrivPredicate.ADMIN)) { + ErrorReport.reportAnalysisException(ErrorCode.ERR_SPECIFIC_ACCESS_DENIED_ERROR, "ADMIN"); + } + + checkProperties(); + } + + private void checkProperties() throws AnalysisException { + partitionId = PropertyAnalyzer.analyzePartitionId(properties); + if (partitionId == -1) { + throw new AnalysisException("Should specify 'partition_id' property."); + } + visibleVersion = PropertyAnalyzer.analyzeVisibleVersion(properties); + if (visibleVersion == -1) { + throw new AnalysisException("Should specify 'visible_version' property."); + } + if (properties != null && !properties.isEmpty()) { + throw new AnalysisException("Unknown properties: " + properties.keySet()); + } + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/catalog/Env.java b/fe/fe-core/src/main/java/org/apache/doris/catalog/Env.java index f25386a83b4df4..2d1a63d1cf59c1 100755 --- a/fe/fe-core/src/main/java/org/apache/doris/catalog/Env.java +++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/Env.java @@ -30,6 +30,7 @@ import org.apache.doris.analysis.AdminCleanTrashStmt; import org.apache.doris.analysis.AdminCompactTableStmt; import org.apache.doris.analysis.AdminSetConfigStmt; +import org.apache.doris.analysis.AdminSetPartitionVersionStmt; import org.apache.doris.analysis.AdminSetReplicaStatusStmt; import org.apache.doris.analysis.AlterDatabasePropertyStmt; import org.apache.doris.analysis.AlterDatabaseQuotaStmt; @@ -190,6 +191,7 @@ import org.apache.doris.persist.RefreshExternalTableInfo; import org.apache.doris.persist.ReplacePartitionOperationLog; import org.apache.doris.persist.ReplicaPersistInfo; +import org.apache.doris.persist.SetPartitionVersionOperationLog; import org.apache.doris.persist.SetReplicaStatusOperationLog; import org.apache.doris.persist.Storage; import org.apache.doris.persist.StorageInfo; @@ -5377,6 +5379,62 @@ public void cleanTrash(AdminCleanTrashStmt stmt) { } } + public void setPartitionVersion(AdminSetPartitionVersionStmt stmt) throws DdlException { + long partitionId = stmt.getPartitionId(); + long versionInfo = stmt.getVisibleVersion(); + int setSuccess = setPartitionVersionInternal(partitionId, versionInfo, false); + if (setSuccess == -1) { + throw new DdlException("Failed to set partition visible version to " + versionInfo + ". " + + "Partition " + partitionId + " not exists."); + } + } + + public void replaySetPartitionVersion(SetPartitionVersionOperationLog log) throws DdlException { + int setSuccess = setPartitionVersionInternal(log.getPartitionId(), log.getVersionInfo(), true); + if (setSuccess == -1) { + LOG.warn("Failed to set partition visible version to {}. Partition {} not exists.", + log.getVersionInfo(), log.getPartitionId()); + } + } + + public int setPartitionVersionInternal(long partitionId, long versionInfo, boolean isReplay) throws DdlException { + int result = -1; + List dbIds = getInternalCatalog().getDbIds(); + // TODO should use inverted index + for (long dbId : dbIds) { + Database database = getInternalCatalog().getDbNullable(dbId); + if (database == null) { + continue; + } + List tables = database.getTables(); + for (Table tbl : tables) { + if (tbl instanceof OlapTable) { + tbl.writeLock(); + try { + Partition partition = ((OlapTable) tbl).getPartition(partitionId); + if (partition != null) { + Long oldVersion = partition.getVisibleVersion(); + partition.updateVisibleVersion(versionInfo); + partition.setNextVersion(versionInfo + 1); + result = 0; + if (!isReplay) { + SetPartitionVersionOperationLog log = new SetPartitionVersionOperationLog( + partitionId, versionInfo); + getEditLog().logSetPartitionVersion(log); + } + LOG.info("set partition {} of table {} visible version from {} to {}", + partitionId, tbl.getId(), oldVersion, versionInfo); + break; + } + } finally { + tbl.writeUnlock(); + } + } + } + } + return result; + } + public static boolean isStoredTableNamesLowerCase() { return GlobalVariable.lowerCaseTableNames == 1; } diff --git a/fe/fe-core/src/main/java/org/apache/doris/common/util/PropertyAnalyzer.java b/fe/fe-core/src/main/java/org/apache/doris/common/util/PropertyAnalyzer.java index a44e75672dde98..4af314162e8e1b 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/common/util/PropertyAnalyzer.java +++ b/fe/fe-core/src/main/java/org/apache/doris/common/util/PropertyAnalyzer.java @@ -71,6 +71,9 @@ public class PropertyAnalyzer { // for restore public static final String PROPERTIES_SCHEMA_VERSION = "schema_version"; + public static final String PROPERTIES_PARTITION_ID = "partition_id"; + public static final String PROPERTIES_VISIBLE_VERSION = "visible_version"; + public static final String PROPERTIES_BF_COLUMNS = "bloom_filter_columns"; public static final String PROPERTIES_BF_FPP = "bloom_filter_fpp"; @@ -427,6 +430,38 @@ public static int analyzeSchemaVersion(Map properties) throws An return schemaVersion; } + public static Long analyzePartitionId(Map properties) throws AnalysisException { + long partitionId = -1; + if (properties != null && properties.containsKey(PROPERTIES_PARTITION_ID)) { + String partitionIdStr = properties.get(PROPERTIES_PARTITION_ID); + try { + partitionId = Long.parseLong(partitionIdStr); + } catch (Exception e) { + throw new AnalysisException("Invalid partition id: " + partitionIdStr); + } + + properties.remove(PROPERTIES_PARTITION_ID); + } + + return partitionId; + } + + public static Long analyzeVisibleVersion(Map properties) throws AnalysisException { + long visibleVersion = -1; + if (properties != null && properties.containsKey(PROPERTIES_VISIBLE_VERSION)) { + String visibleVersionStr = properties.get(PROPERTIES_VISIBLE_VERSION); + try { + visibleVersion = Long.parseLong(visibleVersionStr); + } catch (Exception e) { + throw new AnalysisException("Invalid visible version: " + visibleVersionStr); + } + + properties.remove(PROPERTIES_VISIBLE_VERSION); + } + + return visibleVersion; + } + public static Set analyzeBloomFilterColumns(Map properties, List columns, KeysType keysType) throws AnalysisException { Set bfColumns = null; diff --git a/fe/fe-core/src/main/java/org/apache/doris/journal/JournalEntity.java b/fe/fe-core/src/main/java/org/apache/doris/journal/JournalEntity.java index 34a6e2c77cdd3a..0f62d24cd0cf70 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/journal/JournalEntity.java +++ b/fe/fe-core/src/main/java/org/apache/doris/journal/JournalEntity.java @@ -107,6 +107,7 @@ import org.apache.doris.persist.ReplaceTableOperationLog; import org.apache.doris.persist.ReplicaPersistInfo; import org.apache.doris.persist.RoutineLoadOperation; +import org.apache.doris.persist.SetPartitionVersionOperationLog; import org.apache.doris.persist.SetReplicaStatusOperationLog; import org.apache.doris.persist.TableAddOrDropColumnsInfo; import org.apache.doris.persist.TableAddOrDropInvertedIndicesInfo; @@ -614,6 +615,11 @@ public void readFields(DataInput in) throws IOException { isRead = true; break; } + case OperationType.OP_SET_PARTITION_VERSION: { + data = SetPartitionVersionOperationLog.read(in); + isRead = true; + break; + } case OperationType.OP_DYNAMIC_PARTITION: case OperationType.OP_MODIFY_IN_MEMORY: case OperationType.OP_MODIFY_REPLICATION_NUM: 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 06486fc49cb778..f34c4108b6c423 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 @@ -830,6 +830,11 @@ public static void loadJournal(Env env, Long logId, JournalEntity journal) { env.getAlterInstance().replayModifyComment(operation); break; } + case OperationType.OP_SET_PARTITION_VERSION: { + SetPartitionVersionOperationLog log = (SetPartitionVersionOperationLog) journal.getData(); + env.replaySetPartitionVersion(log); + break; + } case OperationType.OP_ALTER_ROUTINE_LOAD_JOB: { AlterRoutineLoadJobOperationLog log = (AlterRoutineLoadJobOperationLog) journal.getData(); env.getRoutineLoadManager().replayAlterRoutineLoadJob(log); @@ -1734,6 +1739,10 @@ public void logAlterRoutineLoadJob(AlterRoutineLoadJobOperationLog log) { logEdit(OperationType.OP_ALTER_ROUTINE_LOAD_JOB, log); } + public void logSetPartitionVersion(SetPartitionVersionOperationLog log) { + logEdit(OperationType.OP_SET_PARTITION_VERSION, log); + } + public void logGlobalVariableV2(GlobalVarPersistInfo info) { logEdit(OperationType.OP_GLOBAL_VARIABLE_V2, info); } diff --git a/fe/fe-core/src/main/java/org/apache/doris/persist/OperationType.java b/fe/fe-core/src/main/java/org/apache/doris/persist/OperationType.java index 0285272bb5a381..a9dce9cfebb69b 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/persist/OperationType.java +++ b/fe/fe-core/src/main/java/org/apache/doris/persist/OperationType.java @@ -105,6 +105,7 @@ public class OperationType { public static final short OP_BACKEND_TABLETS_INFO = 46; public static final short OP_SET_REPLICA_STATUS = 47; public static final short OP_BACKEND_REPLICAS_INFO = 48; + public static final short OP_SET_PARTITION_VERSION = 49; public static final short OP_ADD_BACKEND = 50; public static final short OP_DROP_BACKEND = 51; diff --git a/fe/fe-core/src/main/java/org/apache/doris/persist/SetPartitionVersionOperationLog.java b/fe/fe-core/src/main/java/org/apache/doris/persist/SetPartitionVersionOperationLog.java new file mode 100644 index 00000000000000..2b65c338360a96 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/persist/SetPartitionVersionOperationLog.java @@ -0,0 +1,60 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package org.apache.doris.persist; + +import org.apache.doris.common.io.Text; +import org.apache.doris.common.io.Writable; +import org.apache.doris.persist.gson.GsonUtils; + +import com.google.gson.annotations.SerializedName; + +import java.io.DataInput; +import java.io.DataOutput; +import java.io.IOException; + +public class SetPartitionVersionOperationLog implements Writable { + + @SerializedName(value = "partitionId") + private long partitionId; + @SerializedName(value = "versionInfo") + private long versionInfo; + + public SetPartitionVersionOperationLog(long partitionId, long versionInfo) { + this.partitionId = partitionId; + this.versionInfo = versionInfo; + } + + public long getPartitionId() { + return partitionId; + } + + public long getVersionInfo() { + return versionInfo; + } + + public static SetPartitionVersionOperationLog read(DataInput in) throws IOException { + String json = Text.readString(in); + return GsonUtils.GSON.fromJson(json, SetPartitionVersionOperationLog.class); + } + + @Override + public void write(DataOutput out) throws IOException { + String json = GsonUtils.GSON.toJson(this); + Text.writeString(out, json); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/qe/DdlExecutor.java b/fe/fe-core/src/main/java/org/apache/doris/qe/DdlExecutor.java index 1d2d31f4163103..739a62704de7f7 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/qe/DdlExecutor.java +++ b/fe/fe-core/src/main/java/org/apache/doris/qe/DdlExecutor.java @@ -25,6 +25,7 @@ import org.apache.doris.analysis.AdminRebalanceDiskStmt; import org.apache.doris.analysis.AdminRepairTableStmt; import org.apache.doris.analysis.AdminSetConfigStmt; +import org.apache.doris.analysis.AdminSetPartitionVersionStmt; import org.apache.doris.analysis.AdminSetReplicaStatusStmt; import org.apache.doris.analysis.AlterCatalogNameStmt; import org.apache.doris.analysis.AlterCatalogPropertyStmt; @@ -267,6 +268,8 @@ public static void execute(Env env, DdlStmt ddlStmt) throws Exception { env.checkTablets((AdminCheckTabletsStmt) ddlStmt); } else if (ddlStmt instanceof AdminSetReplicaStatusStmt) { env.setReplicaStatus((AdminSetReplicaStatusStmt) ddlStmt); + } else if (ddlStmt instanceof AdminSetPartitionVersionStmt) { + env.setPartitionVersion((AdminSetPartitionVersionStmt) ddlStmt); } else if (ddlStmt instanceof CreateResourceStmt) { env.getResourceMgr().createResource((CreateResourceStmt) ddlStmt); } else if (ddlStmt instanceof DropResourceStmt) { diff --git a/fe/fe-core/src/test/java/org/apache/doris/catalog/AdminStmtTest.java b/fe/fe-core/src/test/java/org/apache/doris/catalog/AdminStmtTest.java index c43e08f08f3c4d..c1075062bd30f2 100644 --- a/fe/fe-core/src/test/java/org/apache/doris/catalog/AdminStmtTest.java +++ b/fe/fe-core/src/test/java/org/apache/doris/catalog/AdminStmtTest.java @@ -22,6 +22,7 @@ import org.apache.doris.catalog.Replica.ReplicaStatus; import org.apache.doris.common.AnalysisException; import org.apache.doris.common.Pair; +import org.apache.doris.persist.SetPartitionVersionOperationLog; import org.apache.doris.persist.SetReplicaStatusOperationLog; import org.apache.doris.utframe.TestWithFeService; @@ -50,6 +51,15 @@ protected void runBeforeAll() throws Exception { + "PROPERTIES (\n" + " \"replication_num\" = \"1\"\n" + ");"); + createTable("CREATE TABLE test.tbl2 (\n" + + " `id` int(11) NULL COMMENT \"\",\n" + + " `name` varchar(20) NULL\n" + + ") ENGINE=OLAP\n" + + "DUPLICATE KEY(`id`, `name`)\n" + + "DISTRIBUTED BY HASH(`id`) BUCKETS 3\n" + + "PROPERTIES (\n" + + " \"replication_num\" = \"1\"\n" + + ");"); } @Test @@ -120,4 +130,53 @@ public void testSetReplicaStatusOperationLog() throws IOException, AnalysisExcep } } + @Test + public void testAdminSetPartitionVersion() throws Exception { + Database db = Env.getCurrentInternalCatalog().getDbNullable("default_cluster:test"); + Assertions.assertNotNull(db); + OlapTable tbl = (OlapTable) db.getTableNullable("tbl2"); + Assertions.assertNotNull(tbl); + Partition partition = tbl.getPartitions().iterator().next(); + long partitionId = partition.getId(); + long oldVersion = partition.getVisibleVersion(); + // origin version is 1 + Assertions.assertEquals(1, oldVersion); + // set partition version to 100 + long newVersion = 100; + String adminStmt = "admin set partition version properties ('partition_id' = '" + partitionId + + "', 'visible_version' = '" + newVersion + "');"; + Assertions.assertNotNull(getSqlStmtExecutor(adminStmt)); + Assertions.assertEquals(newVersion, partition.getVisibleVersion()); + adminStmt = "admin set partition version properties ('partition_id' = '" + partitionId + + "', 'visible_version' = '" + oldVersion + "');"; + Assertions.assertNotNull(getSqlStmtExecutor(adminStmt)); + Assertions.assertEquals(oldVersion, partition.getVisibleVersion()); + } + + @Test + public void testSetPartitionVersionOperationLog() throws IOException, AnalysisException { + String fileName = "./SetPartitionVersionOperationLog"; + Path path = Paths.get(fileName); + try { + // 1. Write objects to file + Files.createFile(path); + DataOutputStream out = new DataOutputStream(Files.newOutputStream(path)); + + SetPartitionVersionOperationLog log = new SetPartitionVersionOperationLog(10002, 100); + log.write(out); + out.flush(); + out.close(); + + // 2. Read objects from file + DataInputStream in = new DataInputStream(Files.newInputStream(path)); + + SetPartitionVersionOperationLog readLog = SetPartitionVersionOperationLog.read(in); + Assertions.assertEquals(log.getPartitionId(), readLog.getPartitionId()); + Assertions.assertEquals(log.getVersionInfo(), readLog.getVersionInfo()); + + in.close(); + } finally { + Files.deleteIfExists(path); + } + } } From 5c357944c8eaf425f9d74baa6e6399228f1361c5 Mon Sep 17 00:00:00 2001 From: xy720 Date: Thu, 17 Aug 2023 11:07:20 +0800 Subject: [PATCH 2/5] add docs --- .../ADMIN-SET-PARTITION-VERSION.md | 67 +++++++++++++++++++ .../ADMIN-SET-PARTITION-VERSION.md | 67 +++++++++++++++++++ 2 files changed, 134 insertions(+) create mode 100644 docs/en/docs/sql-manual/sql-reference/Database-Administration-Statements/ADMIN-SET-PARTITION-VERSION.md create mode 100644 docs/zh-CN/docs/sql-manual/sql-reference/Database-Administration-Statements/ADMIN-SET-PARTITION-VERSION.md diff --git a/docs/en/docs/sql-manual/sql-reference/Database-Administration-Statements/ADMIN-SET-PARTITION-VERSION.md b/docs/en/docs/sql-manual/sql-reference/Database-Administration-Statements/ADMIN-SET-PARTITION-VERSION.md new file mode 100644 index 00000000000000..7945525712a2a4 --- /dev/null +++ b/docs/en/docs/sql-manual/sql-reference/Database-Administration-Statements/ADMIN-SET-PARTITION-VERSION.md @@ -0,0 +1,67 @@ +--- +{ + "title": "ADMIN-SET-PARTITION-VERSION", + "language": "en" +} +--- + + + +## ADMIN-SET-PARTITION-VERSION + +### Name + +ADMIN SET PARTITION VERSION + +### Description + +This statement is used to set the version of the specified partition. + +In certain cases, the version of the partition in the metadata may not be consistent with the version of the actual replica. This command can manually set the version of the partition in the metadata. + +grammar: + +```sql +ADMIN SET PARTITION VERSION + PROPERTIES ("key" = "value", ...); +``` + +The following properties are currently supported: + +1. "partition_id": Required. Specify a Partition Id. +2. "visible_version": Required. Specify Version. + +> Note: +> +> It is necessary to first confirm the version of the actual replica on the Be before set the version of the partition. This command is generally only used for emergency troubleshooting, please proceed with caution. + +### Example + +1. Set the version of partition 1769152 to 100. + +```sql +ADMIN SET REPLICA STATUS PROPERTIES("partition_id" = "1769152", "visible_version" = "100"); +``` + +### Keywords + + ADMIN, SET, PARTITION, VERSION + +### Best Practice \ No newline at end of file diff --git a/docs/zh-CN/docs/sql-manual/sql-reference/Database-Administration-Statements/ADMIN-SET-PARTITION-VERSION.md b/docs/zh-CN/docs/sql-manual/sql-reference/Database-Administration-Statements/ADMIN-SET-PARTITION-VERSION.md new file mode 100644 index 00000000000000..a2bd868a5bba40 --- /dev/null +++ b/docs/zh-CN/docs/sql-manual/sql-reference/Database-Administration-Statements/ADMIN-SET-PARTITION-VERSION.md @@ -0,0 +1,67 @@ +--- +{ + "title": "ADMIN-SET-PARTITION-VERSION", + "language": "zh-CN" +} +--- + + + +## ADMIN-SET-PARTITION-VERSION + +### Name + +ADMIN SET PARTITION VERSION + +### Description + +该语句用于手动改变指定分区的可见版本。 + +在某些特殊情况下,元数据中分区的版本有可能和实际副本的版本不一致,该命令可手动改变元数据中分区的版本。 + +语法: + +```sql +ADMIN SET PARTITION VERSION + PROPERTIES ("key" = "value", ...); +``` + +目前支持如下属性: + +1. "partition_id":必需。指定一个 Partition Id. +2. "visible_version":必需。指定 Version. + +> 注意: +> +> 设置分区的版本需要先确认Be机器上实际副本的版本,此命令一般只用于紧急故障修复,请谨慎操作。 + +### Example + +1. 设置 partition 1769152 在 FE 元数据上的版本为 100。 + +```sql +ADMIN SET REPLICA STATUS PROPERTIES("partition_id" = "1769152", "visible_version" = "100"); +``` + +### Keywords + + ADMIN, SET, PARTITION, VERSION + +### Best Practice From 97c7fd5fa8b52bf8bf116ab8207211b0f9473d0a Mon Sep 17 00:00:00 2001 From: xy720 Date: Thu, 17 Aug 2023 20:55:29 +0800 Subject: [PATCH 3/5] save --- .../ADMIN-SET-PARTITION-VERSION.md | 4 ++-- .../ADMIN-SET-PARTITION-VERSION.md | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/en/docs/sql-manual/sql-reference/Database-Administration-Statements/ADMIN-SET-PARTITION-VERSION.md b/docs/en/docs/sql-manual/sql-reference/Database-Administration-Statements/ADMIN-SET-PARTITION-VERSION.md index 7945525712a2a4..a8cfa8f24b0327 100644 --- a/docs/en/docs/sql-manual/sql-reference/Database-Administration-Statements/ADMIN-SET-PARTITION-VERSION.md +++ b/docs/en/docs/sql-manual/sql-reference/Database-Administration-Statements/ADMIN-SET-PARTITION-VERSION.md @@ -57,11 +57,11 @@ The following properties are currently supported: 1. Set the version of partition 1769152 to 100. ```sql -ADMIN SET REPLICA STATUS PROPERTIES("partition_id" = "1769152", "visible_version" = "100"); +ADMIN SET PARTITION VERSION PROPERTIES("partition_id" = "1769152", "visible_version" = "100"); ``` ### Keywords ADMIN, SET, PARTITION, VERSION -### Best Practice \ No newline at end of file +### Best Practice diff --git a/docs/zh-CN/docs/sql-manual/sql-reference/Database-Administration-Statements/ADMIN-SET-PARTITION-VERSION.md b/docs/zh-CN/docs/sql-manual/sql-reference/Database-Administration-Statements/ADMIN-SET-PARTITION-VERSION.md index a2bd868a5bba40..03a98fabb19b8b 100644 --- a/docs/zh-CN/docs/sql-manual/sql-reference/Database-Administration-Statements/ADMIN-SET-PARTITION-VERSION.md +++ b/docs/zh-CN/docs/sql-manual/sql-reference/Database-Administration-Statements/ADMIN-SET-PARTITION-VERSION.md @@ -57,7 +57,7 @@ ADMIN SET PARTITION VERSION 1. 设置 partition 1769152 在 FE 元数据上的版本为 100。 ```sql -ADMIN SET REPLICA STATUS PROPERTIES("partition_id" = "1769152", "visible_version" = "100"); +ADMIN SET PARTITION VERSION PROPERTIES("partition_id" = "1769152", "visible_version" = "100"); ``` ### Keywords From bc47cb50ed80e732792f062a31c5b42b90b3443f Mon Sep 17 00:00:00 2001 From: xy720 Date: Thu, 24 Aug 2023 15:39:04 +0800 Subject: [PATCH 4/5] save code --- fe/fe-core/src/main/cup/sql_parser.cup | 4 +- .../AdminSetPartitionVersionStmt.java | 18 ++++- .../org/apache/doris/catalog/DatabaseIf.java | 9 +++ .../java/org/apache/doris/catalog/Env.java | 69 ++++++++---------- .../doris/common/util/PropertyAnalyzer.java | 35 ++++----- .../SetPartitionVersionOperationLog.java | 27 +++---- .../apache/doris/catalog/AdminStmtTest.java | 16 +++-- .../test_set_partition_version.groovy | 71 +++++++++++++++++++ 8 files changed, 167 insertions(+), 82 deletions(-) create mode 100644 regression-test/suites/version_p0/test_set_partition_version.groovy diff --git a/fe/fe-core/src/main/cup/sql_parser.cup b/fe/fe-core/src/main/cup/sql_parser.cup index 3691bde1934e14..4cc7426ec61a58 100644 --- a/fe/fe-core/src/main/cup/sql_parser.cup +++ b/fe/fe-core/src/main/cup/sql_parser.cup @@ -7216,9 +7216,9 @@ admin_stmt ::= {: RESULT = new AdminCleanTrashStmt(null); :} - | KW_ADMIN KW_SET KW_PARTITION KW_VERSION opt_properties:properties + | KW_ADMIN KW_SET KW_TABLE table_name:name KW_PARTITION KW_VERSION opt_properties:properties {: - RESULT = new AdminSetPartitionVersionStmt(properties); + RESULT = new AdminSetPartitionVersionStmt(name, properties); :} | KW_ADMIN KW_DIAGNOSE KW_TABLET INTEGER_LITERAL:tabletId {: diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/AdminSetPartitionVersionStmt.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/AdminSetPartitionVersionStmt.java index eaf53863ae9f66..a1edeb7a2c8ef8 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/analysis/AdminSetPartitionVersionStmt.java +++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/AdminSetPartitionVersionStmt.java @@ -23,6 +23,7 @@ import org.apache.doris.common.ErrorReport; import org.apache.doris.common.UserException; import org.apache.doris.common.util.PropertyAnalyzer; +import org.apache.doris.common.util.Util; import org.apache.doris.mysql.privilege.PrivPredicate; import org.apache.doris.qe.ConnectContext; @@ -30,19 +31,29 @@ // Modify version of specified partition. Only used in emergency. /* - * admin set partition version properties ("key" = "val", ..); + * admin set table db.tbl partition version properties ("key" = "val", ..); * "partition_id" = "20010", * "visible_version" = "101" */ public class AdminSetPartitionVersionStmt extends DdlStmt { private long partitionId = -1; private long visibleVersion = -1; + private final TableName tableName; private final Map properties; - public AdminSetPartitionVersionStmt(Map properties) { + public AdminSetPartitionVersionStmt(TableName tableName, Map properties) { + this.tableName = tableName; this.properties = properties; } + public String getDatabase() { + return tableName.getDb(); + } + + public String getTable() { + return tableName.getTbl(); + } + public Long getPartitionId() { return partitionId; } @@ -60,6 +71,9 @@ public void analyze(Analyzer analyzer) throws AnalysisException, UserException { ErrorReport.reportAnalysisException(ErrorCode.ERR_SPECIFIC_ACCESS_DENIED_ERROR, "ADMIN"); } + tableName.analyze(analyzer); + Util.prohibitExternalCatalog(tableName.getCtl(), this.getClass().getSimpleName()); + checkProperties(); } diff --git a/fe/fe-core/src/main/java/org/apache/doris/catalog/DatabaseIf.java b/fe/fe-core/src/main/java/org/apache/doris/catalog/DatabaseIf.java index f9c5d94601f787..8c2833764123fa 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/catalog/DatabaseIf.java +++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/DatabaseIf.java @@ -206,6 +206,15 @@ default T getTableOrDdlException(long tableId) throws DdlException { return getTableOrException(tableId, t -> new DdlException(ErrorCode.ERR_BAD_TABLE_ERROR.formatErrorMsg(t))); } + default T getTableOrDdlException(long tableId, TableIf.TableType tableType) throws DdlException { + T table = getTableOrDdlException(tableId); + if (table.getType() != tableType) { + throw new DdlException( + "table type is not " + tableType + ", tableId=" + tableId + ", type=" + table.getType()); + } + return table; + } + default T getTableOrAnalysisException(String tableName) throws AnalysisException { return getTableOrException(tableName, t -> new AnalysisException(ErrorCode.ERR_BAD_TABLE_ERROR.formatErrorMsg(t))); diff --git a/fe/fe-core/src/main/java/org/apache/doris/catalog/Env.java b/fe/fe-core/src/main/java/org/apache/doris/catalog/Env.java index 2d1a63d1cf59c1..06619f77279c8c 100755 --- a/fe/fe-core/src/main/java/org/apache/doris/catalog/Env.java +++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/Env.java @@ -5380,57 +5380,50 @@ public void cleanTrash(AdminCleanTrashStmt stmt) { } public void setPartitionVersion(AdminSetPartitionVersionStmt stmt) throws DdlException { + String database = stmt.getDatabase(); + String table = stmt.getTable(); long partitionId = stmt.getPartitionId(); - long versionInfo = stmt.getVisibleVersion(); - int setSuccess = setPartitionVersionInternal(partitionId, versionInfo, false); + long visibleVersion = stmt.getVisibleVersion(); + int setSuccess = setPartitionVersionInternal(database, table, partitionId, visibleVersion, false); if (setSuccess == -1) { - throw new DdlException("Failed to set partition visible version to " + versionInfo + ". " - + "Partition " + partitionId + " not exists."); + throw new DdlException("Failed to set partition visible version to " + visibleVersion + ". " + "Partition " + + partitionId + " not exists. Database " + database + ", Table " + table + "."); } } public void replaySetPartitionVersion(SetPartitionVersionOperationLog log) throws DdlException { - int setSuccess = setPartitionVersionInternal(log.getPartitionId(), log.getVersionInfo(), true); + int setSuccess = setPartitionVersionInternal(log.getDatabase(), log.getTable(), + log.getPartitionId(), log.getVisibleVersion(), true); if (setSuccess == -1) { - LOG.warn("Failed to set partition visible version to {}. Partition {} not exists.", - log.getVersionInfo(), log.getPartitionId()); + LOG.warn("Failed to set partition visible version to {}. " + + "Database {}, Table {}, Partition {} not exists.", log.getDatabase(), log.getTable(), + log.getVisibleVersion(), log.getPartitionId()); } } - public int setPartitionVersionInternal(long partitionId, long versionInfo, boolean isReplay) throws DdlException { + public int setPartitionVersionInternal(String database, String table, long partitionId, + long visibleVersion, boolean isReplay) throws DdlException { int result = -1; - List dbIds = getInternalCatalog().getDbIds(); - // TODO should use inverted index - for (long dbId : dbIds) { - Database database = getInternalCatalog().getDbNullable(dbId); - if (database == null) { - continue; - } - List
tables = database.getTables(); - for (Table tbl : tables) { - if (tbl instanceof OlapTable) { - tbl.writeLock(); - try { - Partition partition = ((OlapTable) tbl).getPartition(partitionId); - if (partition != null) { - Long oldVersion = partition.getVisibleVersion(); - partition.updateVisibleVersion(versionInfo); - partition.setNextVersion(versionInfo + 1); - result = 0; - if (!isReplay) { - SetPartitionVersionOperationLog log = new SetPartitionVersionOperationLog( - partitionId, versionInfo); - getEditLog().logSetPartitionVersion(log); - } - LOG.info("set partition {} of table {} visible version from {} to {}", - partitionId, tbl.getId(), oldVersion, versionInfo); - break; - } - } finally { - tbl.writeUnlock(); - } + Database db = getInternalCatalog().getDbOrDdlException(database); + OlapTable olapTable = db.getOlapTableOrDdlException(table); + olapTable.writeLockOrDdlException(); + try { + Partition partition = olapTable.getPartition(partitionId); + if (partition != null) { + Long oldVersion = partition.getVisibleVersion(); + partition.updateVisibleVersion(visibleVersion); + partition.setNextVersion(visibleVersion + 1); + result = 0; + if (!isReplay) { + SetPartitionVersionOperationLog log = new SetPartitionVersionOperationLog( + database, table, partitionId, visibleVersion); + getEditLog().logSetPartitionVersion(log); } + LOG.info("set partition {} visible version from {} to {}. Database {}, Table {}, is replay:" + + " {}.", partitionId, oldVersion, visibleVersion, database, table, isReplay); } + } finally { + olapTable.writeUnlock(); } return result; } diff --git a/fe/fe-core/src/main/java/org/apache/doris/common/util/PropertyAnalyzer.java b/fe/fe-core/src/main/java/org/apache/doris/common/util/PropertyAnalyzer.java index 4af314162e8e1b..95cbbc348e3aca 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/common/util/PropertyAnalyzer.java +++ b/fe/fe-core/src/main/java/org/apache/doris/common/util/PropertyAnalyzer.java @@ -70,7 +70,6 @@ public class PropertyAnalyzer { public static final String PROPERTIES_VERSION_INFO = "version_info"; // for restore public static final String PROPERTIES_SCHEMA_VERSION = "schema_version"; - public static final String PROPERTIES_PARTITION_ID = "partition_id"; public static final String PROPERTIES_VISIBLE_VERSION = "visible_version"; @@ -430,36 +429,28 @@ public static int analyzeSchemaVersion(Map properties) throws An return schemaVersion; } - public static Long analyzePartitionId(Map properties) throws AnalysisException { - long partitionId = -1; - if (properties != null && properties.containsKey(PROPERTIES_PARTITION_ID)) { - String partitionIdStr = properties.get(PROPERTIES_PARTITION_ID); + private static Long getPropertyLong(Map properties, String propertyId) throws AnalysisException { + long id = -1; + if (properties != null && properties.containsKey(propertyId)) { + String propertyIdStr = properties.get(propertyId); try { - partitionId = Long.parseLong(partitionIdStr); + id = Long.parseLong(propertyIdStr); } catch (Exception e) { - throw new AnalysisException("Invalid partition id: " + partitionIdStr); + throw new AnalysisException("Invalid property long id: " + propertyIdStr); } - properties.remove(PROPERTIES_PARTITION_ID); + properties.remove(propertyId); } - return partitionId; + return id; } - public static Long analyzeVisibleVersion(Map properties) throws AnalysisException { - long visibleVersion = -1; - if (properties != null && properties.containsKey(PROPERTIES_VISIBLE_VERSION)) { - String visibleVersionStr = properties.get(PROPERTIES_VISIBLE_VERSION); - try { - visibleVersion = Long.parseLong(visibleVersionStr); - } catch (Exception e) { - throw new AnalysisException("Invalid visible version: " + visibleVersionStr); - } - - properties.remove(PROPERTIES_VISIBLE_VERSION); - } + public static Long analyzePartitionId(Map properties) throws AnalysisException { + return getPropertyLong(properties, PROPERTIES_PARTITION_ID); + } - return visibleVersion; + public static Long analyzeVisibleVersion(Map properties) throws AnalysisException { + return getPropertyLong(properties, PROPERTIES_VISIBLE_VERSION); } public static Set analyzeBloomFilterColumns(Map properties, List columns, diff --git a/fe/fe-core/src/main/java/org/apache/doris/persist/SetPartitionVersionOperationLog.java b/fe/fe-core/src/main/java/org/apache/doris/persist/SetPartitionVersionOperationLog.java index 2b65c338360a96..ae5b3a4c382fbc 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/persist/SetPartitionVersionOperationLog.java +++ b/fe/fe-core/src/main/java/org/apache/doris/persist/SetPartitionVersionOperationLog.java @@ -22,29 +22,32 @@ import org.apache.doris.persist.gson.GsonUtils; import com.google.gson.annotations.SerializedName; +import lombok.Getter; import java.io.DataInput; import java.io.DataOutput; import java.io.IOException; +@Getter public class SetPartitionVersionOperationLog implements Writable { + @SerializedName(value = "database") + private String database; + + @SerializedName(value = "table") + private String table; + @SerializedName(value = "partitionId") private long partitionId; - @SerializedName(value = "versionInfo") - private long versionInfo; - public SetPartitionVersionOperationLog(long partitionId, long versionInfo) { - this.partitionId = partitionId; - this.versionInfo = versionInfo; - } + @SerializedName(value = "visibleVersion") + private long visibleVersion; - public long getPartitionId() { - return partitionId; - } - - public long getVersionInfo() { - return versionInfo; + public SetPartitionVersionOperationLog(String database, String table, long partitionId, long visibleVersion) { + this.database = database; + this.table = table; + this.partitionId = partitionId; + this.visibleVersion = visibleVersion; } public static SetPartitionVersionOperationLog read(DataInput in) throws IOException { diff --git a/fe/fe-core/src/test/java/org/apache/doris/catalog/AdminStmtTest.java b/fe/fe-core/src/test/java/org/apache/doris/catalog/AdminStmtTest.java index c1075062bd30f2..5d994350600842 100644 --- a/fe/fe-core/src/test/java/org/apache/doris/catalog/AdminStmtTest.java +++ b/fe/fe-core/src/test/java/org/apache/doris/catalog/AdminStmtTest.java @@ -143,12 +143,12 @@ public void testAdminSetPartitionVersion() throws Exception { Assertions.assertEquals(1, oldVersion); // set partition version to 100 long newVersion = 100; - String adminStmt = "admin set partition version properties ('partition_id' = '" + partitionId - + "', 'visible_version' = '" + newVersion + "');"; + String adminStmt = "admin set table test.tbl2 partition version properties ('partition_id' = '" + + partitionId + "', " + "'visible_version' = '" + newVersion + "');"; Assertions.assertNotNull(getSqlStmtExecutor(adminStmt)); Assertions.assertEquals(newVersion, partition.getVisibleVersion()); - adminStmt = "admin set partition version properties ('partition_id' = '" + partitionId - + "', 'visible_version' = '" + oldVersion + "');"; + adminStmt = "admin set table test.tbl2 partition version properties ('partition_id' = '" + + partitionId + "', " + "'visible_version' = '" + oldVersion + "');"; Assertions.assertNotNull(getSqlStmtExecutor(adminStmt)); Assertions.assertEquals(oldVersion, partition.getVisibleVersion()); } @@ -162,7 +162,8 @@ public void testSetPartitionVersionOperationLog() throws IOException, AnalysisEx Files.createFile(path); DataOutputStream out = new DataOutputStream(Files.newOutputStream(path)); - SetPartitionVersionOperationLog log = new SetPartitionVersionOperationLog(10002, 100); + SetPartitionVersionOperationLog log = new SetPartitionVersionOperationLog( + "test", "tbl2", 10002, 100); log.write(out); out.flush(); out.close(); @@ -171,12 +172,15 @@ public void testSetPartitionVersionOperationLog() throws IOException, AnalysisEx DataInputStream in = new DataInputStream(Files.newInputStream(path)); SetPartitionVersionOperationLog readLog = SetPartitionVersionOperationLog.read(in); + Assertions.assertEquals(log.getDatabase(), readLog.getDatabase()); + Assertions.assertEquals(log.getTable(), readLog.getTable()); Assertions.assertEquals(log.getPartitionId(), readLog.getPartitionId()); - Assertions.assertEquals(log.getVersionInfo(), readLog.getVersionInfo()); + Assertions.assertEquals(log.getVisibleVersion(), readLog.getVisibleVersion()); in.close(); } finally { Files.deleteIfExists(path); } } + } diff --git a/regression-test/suites/version_p0/test_set_partition_version.groovy b/regression-test/suites/version_p0/test_set_partition_version.groovy new file mode 100644 index 00000000000000..b461d01d800eae --- /dev/null +++ b/regression-test/suites/version_p0/test_set_partition_version.groovy @@ -0,0 +1,71 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +suite("test_set_partition_version") { + def tableName1 = "test_set_partition_version" + sql """ DROP TABLE IF EXISTS ${tableName1} """ + sql """ + CREATE TABLE ${tableName1} ( + `id` int NOT NULL, + `version` int NOT NULL COMMENT '插入次数' + ) ENGINE=OLAP + DUPLICATE KEY(`id`) + COMMENT 'OLAP' + DISTRIBUTED BY HASH(`id`) BUCKETS 10 + PROPERTIES + ( + "replication_allocation" = "tag.location.default: 1", + "disable_auto_compaction" = "true" + ); + """ + + def res = sql """ show partitions from ${tableName1}; """ + def partitionId = res[0][0].toString() + + // load 1 time, partition visible version should be 2 + sql """ insert into ${tableName1} values (1, 2); """ + res = sql """ show partitions from ${tableName1}; """ + assertEquals(res[0][2].toString(), "2") + + // load 2 time, partition visible version should be 3 + sql """ insert into ${tableName1} values (2, 3); """ + res = sql """ show partitions from ${tableName1}; """ + assertEquals(res[0][2].toString(), "3") + + // set partition visible version to 2 + sql """ ADMIN SET TABLE ${tableName1} PARTITION VERSION PROPERTIES ("partition_id" = "${partitionId}", "visible_version" = "2"); """ + res = sql """ show partitions from ${tableName1}; """ + assertEquals(res[0][2].toString(), "2") + + // check if table can query, and return row size should be 1 + res = sql """ select * from ${tableName1}; """ + assertEquals(res.size(), 1) + + // set partition visible version to 3 + sql """ ADMIN SET TABLE ${tableName1} PARTITION VERSION PROPERTIES ("partition_id" = "${partitionId}", "visible_version" = "3"); """ + res = sql """ show partitions from ${tableName1}; """ + assertEquals(res[0][2].toString(), "3") + + // check if table can query, and return row size should be 2 + res = sql """ select * from ${tableName1}; """ + assertEquals(res.size(), 2) + + // load 3 time, partition visible version should be 4 + sql """ insert into ${tableName1} values (3, 4); """ + res = sql """ show partitions from ${tableName1}; """ + assertEquals(res[0][2].toString(), "4") +} From f21fe8a964b73b480acb763cd25d3d9fb1ec07d7 Mon Sep 17 00:00:00 2001 From: xy720 Date: Thu, 24 Aug 2023 15:46:30 +0800 Subject: [PATCH 5/5] save --- .../ADMIN-SET-PARTITION-VERSION.md | 4 ++-- docs/sidebars.json | 1 + .../ADMIN-SET-PARTITION-VERSION.md | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/docs/en/docs/sql-manual/sql-reference/Database-Administration-Statements/ADMIN-SET-PARTITION-VERSION.md b/docs/en/docs/sql-manual/sql-reference/Database-Administration-Statements/ADMIN-SET-PARTITION-VERSION.md index a8cfa8f24b0327..14e63036bdc3bf 100644 --- a/docs/en/docs/sql-manual/sql-reference/Database-Administration-Statements/ADMIN-SET-PARTITION-VERSION.md +++ b/docs/en/docs/sql-manual/sql-reference/Database-Administration-Statements/ADMIN-SET-PARTITION-VERSION.md @@ -39,7 +39,7 @@ In certain cases, the version of the partition in the metadata may not be consis grammar: ```sql -ADMIN SET PARTITION VERSION +ADMIN SET TABLE table_name PARTITION VERSION PROPERTIES ("key" = "value", ...); ``` @@ -57,7 +57,7 @@ The following properties are currently supported: 1. Set the version of partition 1769152 to 100. ```sql -ADMIN SET PARTITION VERSION PROPERTIES("partition_id" = "1769152", "visible_version" = "100"); +ADMIN SET TABLE tbl1 PARTITION VERSION PROPERTIES("partition_id" = "1769152", "visible_version" = "100"); ``` ### Keywords diff --git a/docs/sidebars.json b/docs/sidebars.json index c1329d4f47dd7b..6988d3ed73a305 100644 --- a/docs/sidebars.json +++ b/docs/sidebars.json @@ -812,6 +812,7 @@ "sql-manual/sql-reference/Database-Administration-Statements/INSTALL-PLUGIN", "sql-manual/sql-reference/Database-Administration-Statements/UNINSTALL-PLUGIN", "sql-manual/sql-reference/Database-Administration-Statements/ADMIN-SET-REPLICA-STATUS", + "sql-manual/sql-reference/Database-Administration-Statements/ADMIN-SET-PARTITION-VERSION", "sql-manual/sql-reference/Database-Administration-Statements/ADMIN-SHOW-REPLICA-DISTRIBUTION", "sql-manual/sql-reference/Database-Administration-Statements/ADMIN-SHOW-REPLICA-STATUS", "sql-manual/sql-reference/Database-Administration-Statements/ADMIN-REPAIR-TABLE", diff --git a/docs/zh-CN/docs/sql-manual/sql-reference/Database-Administration-Statements/ADMIN-SET-PARTITION-VERSION.md b/docs/zh-CN/docs/sql-manual/sql-reference/Database-Administration-Statements/ADMIN-SET-PARTITION-VERSION.md index 03a98fabb19b8b..3ce8d43cd685a9 100644 --- a/docs/zh-CN/docs/sql-manual/sql-reference/Database-Administration-Statements/ADMIN-SET-PARTITION-VERSION.md +++ b/docs/zh-CN/docs/sql-manual/sql-reference/Database-Administration-Statements/ADMIN-SET-PARTITION-VERSION.md @@ -39,7 +39,7 @@ ADMIN SET PARTITION VERSION 语法: ```sql -ADMIN SET PARTITION VERSION +ADMIN SET TABLE table_name PARTITION VERSION PROPERTIES ("key" = "value", ...); ``` @@ -57,7 +57,7 @@ ADMIN SET PARTITION VERSION 1. 设置 partition 1769152 在 FE 元数据上的版本为 100。 ```sql -ADMIN SET PARTITION VERSION PROPERTIES("partition_id" = "1769152", "visible_version" = "100"); +ADMIN SET TABLE tbl1 PARTITION VERSION PROPERTIES("partition_id" = "1769152", "visible_version" = "100"); ``` ### Keywords