This is an automated email from the ASF dual-hosted git repository.
yiguolei pushed a commit to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-2.0 by this push:
new 113a6f05be9 [fix](mysqldb) Fix mysqldb upgrade (#25111)
113a6f05be9 is described below
commit 113a6f05be9e597674c96f09c8e8dfaf52a209d9
Author: zhiqqqq <[email protected]>
AuthorDate: Sun Oct 8 20:40:56 2023 -0500
[fix](mysqldb) Fix mysqldb upgrade (#25111)
If user has database with same name mysql, will introduce problem when
doing checkpoint.
Solution:
Add check for this situation, if duplicate, exit and print log info to
prevent damage of metadata;
Add fe config field: mysqldb_replace_name to make things correct if user
already has mysql db.
Related pr: #23087 #22868
---
docs/en/docs/admin-manual/config/fe-config.md | 5 +++++
docs/zh-CN/docs/admin-manual/config/fe-config.md | 8 +++++++-
.../src/main/java/org/apache/doris/common/Config.java | 9 +++++++++
.../main/java/org/apache/doris/analysis/DropDbStmt.java | 11 ++++++-----
.../src/main/java/org/apache/doris/catalog/MysqlDb.java | 3 ++-
.../java/org/apache/doris/datasource/InternalCatalog.java | 15 +++++++++++++++
6 files changed, 44 insertions(+), 7 deletions(-)
diff --git a/docs/en/docs/admin-manual/config/fe-config.md
b/docs/en/docs/admin-manual/config/fe-config.md
index eafe9938c09..968cc4c4bd6 100644
--- a/docs/en/docs/admin-manual/config/fe-config.md
+++ b/docs/en/docs/admin-manual/config/fe-config.md
@@ -2759,3 +2759,8 @@ Default:true
Temporary configuration option. After it is enabled, a background thread will
be started to automatically modify all olap tables to light schema change. The
modification results can be viewed through the command `show
convert_light_schema_change [from db]`, and the conversion results of all
non-light schema change tables will be displayed.
+#### `mysqldb_replace_name`
+
+Default: mysql
+
+To ensure compatibility with the MySQL ecosystem, Doris includes a built-in
database called mysql. If this database conflicts with a user's own database,
please modify this field to replace the name of the Doris built-in MySQL
database with a different name.
\ No newline at end of file
diff --git a/docs/zh-CN/docs/admin-manual/config/fe-config.md
b/docs/zh-CN/docs/admin-manual/config/fe-config.md
index e8be232bfcf..067fc4751f1 100644
--- a/docs/zh-CN/docs/admin-manual/config/fe-config.md
+++ b/docs/zh-CN/docs/admin-manual/config/fe-config.md
@@ -2759,4 +2759,10 @@ show data (其他用法:HELP SHOW DATA)
默认值:true
-暂时性配置项,开启后会启动后台线程自动将所有的olap表修改为可light schema change,修改结果可通过命令`show
convert_light_schema_change [from db]` 来查看,将会展示所有非light schema change表的转换结果
\ No newline at end of file
+暂时性配置项,开启后会启动后台线程自动将所有的olap表修改为可light schema change,修改结果可通过命令`show
convert_light_schema_change [from db]` 来查看,将会展示所有非light schema change表的转换结果
+
+#### `mysqldb_replace_name`
+
+Default: mysql
+
+Doris 为了兼用 mysql 周边工具生态,会内置一个名为 mysql 的数据库,如果该数据库与用户自建数据库冲突,请修改这个字段,为 doris
内置的 mysql database 更换一个名字
diff --git a/fe/fe-common/src/main/java/org/apache/doris/common/Config.java
b/fe/fe-common/src/main/java/org/apache/doris/common/Config.java
index b9de274eada..2897b9f890e 100644
--- a/fe/fe-common/src/main/java/org/apache/doris/common/Config.java
+++ b/fe/fe-common/src/main/java/org/apache/doris/common/Config.java
@@ -2177,4 +2177,13 @@ public class Config extends ConfigBase {
"min buckets of auto bucket"
})
public static int autobucket_min_buckets = 1;
+
+ @ConfField(mutable = true, description = {
+ "Doris 为了兼用 mysql 周边工具生态,会内置一个名为 mysql 的数据库,如果该数据库与用户自建数据库冲突,"
+ + "请修改这个字段,为 doris 内置的 mysql database 更换一个名字",
+ "To ensure compatibility with the MySQL ecosystem, Doris includes
a built-in database called mysql. "
+ + "If this database conflicts with a user's own database, please
modify this field to replace "
+ + "the name of the Doris built-in MySQL database with a different
name."})
+ public static String mysqldb_replace_name = "mysql";
+
}
diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/DropDbStmt.java
b/fe/fe-core/src/main/java/org/apache/doris/analysis/DropDbStmt.java
index 2172477c29d..f4edb5a408a 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/DropDbStmt.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/DropDbStmt.java
@@ -17,9 +17,9 @@
package org.apache.doris.analysis;
+import org.apache.doris.catalog.Database;
+import org.apache.doris.catalog.DatabaseIf;
import org.apache.doris.catalog.Env;
-import org.apache.doris.catalog.InfoSchemaDb;
-import org.apache.doris.catalog.MysqlDb;
import org.apache.doris.cluster.ClusterNamespace;
import org.apache.doris.common.ErrorCode;
import org.apache.doris.common.ErrorReport;
@@ -60,9 +60,10 @@ public class DropDbStmt extends DdlStmt {
ErrorReport.reportAnalysisException(ErrorCode.ERR_WRONG_DB_NAME,
dbName);
}
dbName = ClusterNamespace.getFullName(getClusterName(), dbName);
- // Don't allowed to drop 'information_schema' & 'mysql'
- if
(dbName.equalsIgnoreCase(ClusterNamespace.getFullName(getClusterName(),
InfoSchemaDb.DATABASE_NAME))
- ||
dbName.equalsIgnoreCase(ClusterNamespace.getFullName(getClusterName(),
MysqlDb.DATABASE_NAME))) {
+
+ // Don't allow to drop mysql compatible databases
+ DatabaseIf db = Env.getCurrentInternalCatalog().getDbNullable(dbName);
+ if (db != null && (db instanceof Database) && ((Database)
db).isMysqlCompatibleDatabase()) {
ErrorReport.reportAnalysisException(ErrorCode.ERR_DBACCESS_DENIED_ERROR,
analyzer.getQualifiedUser(), dbName);
}
diff --git a/fe/fe-core/src/main/java/org/apache/doris/catalog/MysqlDb.java
b/fe/fe-core/src/main/java/org/apache/doris/catalog/MysqlDb.java
index 5e6bd65507b..58ba36764f1 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/catalog/MysqlDb.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/MysqlDb.java
@@ -18,6 +18,7 @@
package org.apache.doris.catalog;
import org.apache.doris.cluster.ClusterNamespace;
+import org.apache.doris.common.Config;
/**
* This class is used for MySQL compatibility.
@@ -33,7 +34,7 @@ import org.apache.doris.cluster.ClusterNamespace;
* We will add useful system tables in the future.
*/
public class MysqlDb extends MysqlCompatibleDatabase {
- public static final String DATABASE_NAME = "mysql";
+ public static final String DATABASE_NAME = Config.mysqldb_replace_name;
/**
* Database created by user will have database id starting from 10000
{@link Env#NEXT_ID_INIT_VALUE}.
* InfoSchemaDb takes id 0, so we assign id 1 to MysqlDb.
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/datasource/InternalCatalog.java
b/fe/fe-core/src/main/java/org/apache/doris/datasource/InternalCatalog.java
index 866d99db4a4..308fe182997 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/datasource/InternalCatalog.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/datasource/InternalCatalog.java
@@ -3140,6 +3140,21 @@ public class InternalCatalog implements
CatalogIf<Database> {
Database db = new Database();
db.readFields(dis);
newChecksum ^= db.getId();
+
+ Database dbPrev = fullNameToDb.get(db.getFullName());
+ if (dbPrev != null) {
+ String errMsg;
+ if (dbPrev.isMysqlCompatibleDatabase() ||
db.isMysqlCompatibleDatabase()) {
+ errMsg = String.format(
+ "Mysql compatibility problem, previous checkpoint
already has a database with full name "
+ + "%s. If its name is mysql, try to add
mysqldb_replace_name=\"mysql_comp\" in fe.conf.",
+ db.getFullName());
+ } else {
+ errMsg = String.format("Logical error, duplicated database
fullname: %s, id: %d %d.",
+ db.getFullName(), db.getId(),
fullNameToDb.get(db.getFullName()).getId());
+ }
+ throw new IOException(errMsg);
+ }
idToDb.put(db.getId(), db);
fullNameToDb.put(db.getFullName(), db);
Env.getCurrentGlobalTransactionMgr().addDatabaseTransactionMgr(db.getId());
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]