Skip to content

Commit

Permalink
branch-2.1: [fix](external catalog) Fixed non-master FE log replay du…
Browse files Browse the repository at this point in the history
…ring refresh (apache#46373)

cherry-pick apache#46369
  • Loading branch information
zy-kkk authored Jan 3, 2025
1 parent 69de40c commit e9921d7
Show file tree
Hide file tree
Showing 11 changed files with 72 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -718,7 +718,7 @@ private void removeAccessController() {

public void replayInitCatalog(InitCatalogLog log) {
// If the remote name is missing during upgrade, all databases in the Map will be reinitialized.
if (log.getRemoteDbNames() == null || log.getRemoteDbNames().isEmpty()) {
if (log.getCreateCount() > 0 && (log.getRemoteDbNames() == null || log.getRemoteDbNames().isEmpty())) {
dbNameToId = Maps.newConcurrentMap();
idToDb = Maps.newConcurrentMap();
lastUpdateTime = log.getLastUpdateTime();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ public final synchronized void makeSureInitialized() {

public void replayInitDb(InitDatabaseLog log, ExternalCatalog catalog) {
// If the remote name is missing during upgrade, all tables in the Map will be reinitialized.
if (log.getRemoteTableNames() == null || log.getRemoteTableNames().isEmpty()) {
if (log.getCreateCount() > 0 && (log.getRemoteTableNames() == null || log.getRemoteTableNames().isEmpty())) {
tableNameToId = Maps.newConcurrentMap();
idToTbl = Maps.newConcurrentMap();
lastUpdateTime = log.getLastUpdateTime();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,16 @@
suite("test_conflict_name", "p0,external,doris,meta_names_mapping") {

String jdbcUrl = context.config.jdbcUrl
String jdbcUser = context.config.jdbcUser
String jdbcPassword = context.config.jdbcPassword
String jdbcUser = "test_conflict_name_user"
String jdbcPassword = "C123_567p"
String s3_endpoint = getS3Endpoint()
String bucket = getS3BucketName()
String driver_url = "https://${bucket}.${s3_endpoint}/regression/jdbc_driver/mysql-connector-j-8.3.0.jar"

try_sql """drop user ${jdbcUser}"""
sql """create user ${jdbcUser} identified by '${jdbcPassword}'"""
sql """grant all on *.*.* to ${jdbcUser}"""

sql """drop database if exists internal.external_conflict_name; """
sql """drop database if exists internal.EXTERNAL_CONFLICT_NAME; """
sql """create database if not exists internal.external_conflict_name; """
Expand Down Expand Up @@ -91,4 +95,6 @@ suite("test_conflict_name", "p0,external,doris,meta_names_mapping") {

sql """drop database if exists internal.external_conflict_name; """
sql """drop database if exists internal.EXTERNAL_CONFLICT_NAME; """

try_sql """drop user ${jdbcUser}"""
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,16 @@
suite("test_lower_case_meta_include", "p0,external,doris,external_docker,external_docker_doris") {

String jdbcUrl = context.config.jdbcUrl
String jdbcUser = context.config.jdbcUser
String jdbcPassword = context.config.jdbcPassword
String jdbcUser = "test_lower_include_user"
String jdbcPassword = "C123_567p"
String s3_endpoint = getS3Endpoint()
String bucket = getS3BucketName()
String driver_url = "https://${bucket}.${s3_endpoint}/regression/jdbc_driver/mysql-connector-j-8.3.0.jar"

try_sql """drop user ${jdbcUser}"""
sql """create user ${jdbcUser} identified by '${jdbcPassword}'"""
sql """grant all on *.*.* to ${jdbcUser}"""

String mapping_db = """
{
"databases": [
Expand Down Expand Up @@ -155,4 +159,6 @@ suite("test_lower_case_meta_include", "p0,external,doris,external_docker,externa
sql """drop catalog if exists test_lower_case_exclude """
sql """drop database if exists internal.external_INCLUDE; """
sql """drop database if exists internal.external_EXCLUDE; """

try_sql """drop user ${jdbcUser}"""
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,16 @@
suite("test_lower_case_meta_show_and_select", "p0,external,doris,external_docker,external_docker_doris") {

String jdbcUrl = context.config.jdbcUrl
String jdbcUser = context.config.jdbcUser
String jdbcPassword = context.config.jdbcPassword
String jdbcUser = "test_lower_without_conf_user"
String jdbcPassword = "C123_567p"
String s3_endpoint = getS3Endpoint()
String bucket = getS3BucketName()
String driver_url = "https://${bucket}.${s3_endpoint}/regression/jdbc_driver/mysql-connector-j-8.3.0.jar"

try_sql """drop user ${jdbcUser}"""
sql """create user ${jdbcUser} identified by '${jdbcPassword}'"""
sql """grant all on *.*.* to ${jdbcUser}"""

sql """drop database if exists internal.external_test_lower; """
sql """drop database if exists internal.external_test_UPPER; """
sql """create database if not exists internal.external_test_lower; """
Expand Down Expand Up @@ -251,4 +255,6 @@ suite("test_lower_case_meta_show_and_select", "p0,external,doris,external_docker

sql """drop database if exists internal.external_test_lower; """
sql """drop database if exists internal.external_test_UPPER; """

try_sql """drop user ${jdbcUser}"""
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,17 @@
suite("test_lower_case_meta_with_lower_table_conf_show_and_select", "p0,external,doris,external_docker,external_docker_doris") {

String jdbcUrl = context.config.jdbcUrl
String jdbcUser = context.config.jdbcUser
String jdbcPassword = context.config.jdbcPassword
String jdbcUser = "test_lower_with_conf"
String jdbcPassword = "C123_567p"
String s3_endpoint = getS3Endpoint()
String bucket = getS3BucketName()
String driver_url = "https://${bucket}.${s3_endpoint}/regression/jdbc_driver/mysql-connector-j-8.3.0.jar"

try_sql """drop user ${jdbcUser}"""
sql """create user ${jdbcUser} identified by '${jdbcPassword}'"""
sql """grant all on *.*.* to ${jdbcUser}"""

sql """drop database if exists internal.external_test_lower_with_conf; """
sql """drop database if exists internal.external_test_UPPER_with_conf; """
sql """create database if not exists internal.external_test_lower_with_conf; """
sql """create table if not exists internal.external_test_lower_with_conf.lower_with_conf
(id int, name varchar(20))
Expand Down Expand Up @@ -699,4 +702,6 @@ suite("test_lower_case_meta_with_lower_table_conf_show_and_select", "p0,external
sql """drop catalog if exists test_cache_true_lower_true_with_conf0 """

sql """drop database if exists internal.external_test_lower_with_conf; """

try_sql """drop user ${jdbcUser}"""
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,16 @@
suite("test_lower_case_mtmv", "p0,external,doris,external_docker,external_docker_doris") {

String jdbcUrl = context.config.jdbcUrl
String jdbcUser = context.config.jdbcUser
String jdbcPassword = context.config.jdbcPassword
String jdbcUser = "test_lower_case_mtmv_user"
String jdbcPassword = "C123_567p"
String s3_endpoint = getS3Endpoint()
String bucket = getS3BucketName()
String driver_url = "https://${bucket}.${s3_endpoint}/regression/jdbc_driver/mysql-connector-j-8.3.0.jar"

try_sql """drop user ${jdbcUser}"""
sql """create user ${jdbcUser} identified by '${jdbcPassword}'"""
sql """grant all on *.*.* to ${jdbcUser}"""

sql """drop database if exists internal.EXTERNAL_LOWER_MTMV; """
sql """create database if not exists internal.EXTERNAL_LOWER_MTMV;"""
sql """create table if not exists internal.EXTERNAL_LOWER_MTMV.TABLE_TEST
Expand Down Expand Up @@ -61,4 +65,6 @@ suite("test_lower_case_mtmv", "p0,external,doris,external_docker,external_docker

sql """drop catalog if exists test_lower_case_mtmv """
sql """drop database if exists internal.EXTERNAL_LOWER_MTMV """

try_sql """drop user ${jdbcUser}"""
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,16 @@
suite("test_meta_cache_select_without_refresh", "p0,external,doris,external_docker,external_docker_doris") {

String jdbcUrl = context.config.jdbcUrl
String jdbcUser = context.config.jdbcUser
String jdbcPassword = context.config.jdbcPassword
String jdbcUser = "test_meta_cache_select_without_refresh_user"
String jdbcPassword = "C123_567p"
String s3_endpoint = getS3Endpoint()
String bucket = getS3BucketName()
String driver_url = "https://${bucket}.${s3_endpoint}/regression/jdbc_driver/mysql-connector-j-8.3.0.jar"

try_sql """drop user ${jdbcUser}"""
sql """create user ${jdbcUser} identified by '${jdbcPassword}'"""
sql """grant all on *.*.* to ${jdbcUser}"""

sql """ drop database if exists internal.external_lower_select_without_refresh; """
sql """create database if not exists internal.external_lower_select_without_refresh;"""

Expand Down Expand Up @@ -89,4 +93,6 @@ suite("test_meta_cache_select_without_refresh", "p0,external,doris,external_dock
sql """drop catalog if exists test_meta_cache_lower_true_select_without_refresh """
sql """drop catalog if exists test_meta_cache_lower_false_select_without_refresh """
sql """drop database if exists internal.external_lower_select_without_refresh; """

try_sql """drop user ${jdbcUser}"""
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,16 @@
suite("test_meta_names_mapping", "p0,external,doris,meta_names_mapping") {

String jdbcUrl = context.config.jdbcUrl
String jdbcUser = context.config.jdbcUser
String jdbcPassword = context.config.jdbcPassword
String jdbcUser = "test_meta_names_mapping_user"
String jdbcPassword = "C123_567p"
String s3_endpoint = getS3Endpoint()
String bucket = getS3BucketName()
String driver_url = "https://${bucket}.${s3_endpoint}/regression/jdbc_driver/mysql-connector-j-8.3.0.jar"

try_sql """drop user ${jdbcUser}"""
sql """create user ${jdbcUser} identified by '${jdbcPassword}'"""
sql """grant all on *.*.* to ${jdbcUser}"""

String validMetaNamesMapping = """
{
"databases": [
Expand Down Expand Up @@ -286,4 +290,6 @@ suite("test_meta_names_mapping", "p0,external,doris,meta_names_mapping") {

sql """drop database if exists internal.external_meta_names_mapping; """
sql """drop database if exists internal.EXTERNAL_META_NAMES_MAPPING; """

try_sql """drop user ${jdbcUser}"""
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,16 @@
suite("test_timing_refresh_catalog", "p0,external,doris,external_docker,external_docker_doris") {

String jdbcUrl = context.config.jdbcUrl
String jdbcUser = context.config.jdbcUser
String jdbcPassword = context.config.jdbcPassword
String jdbcUser = "test_timing_refresh_catalog_user"
String jdbcPassword = "C123_567p"
String s3_endpoint = getS3Endpoint()
String bucket = getS3BucketName()
String driver_url = "https://${bucket}.${s3_endpoint}/regression/jdbc_driver/mysql-connector-j-8.3.0.jar"

try_sql """drop user ${jdbcUser}"""
sql """create user ${jdbcUser} identified by '${jdbcPassword}'"""
sql """grant all on *.*.* to ${jdbcUser}"""

String mapping = """
{
"databases": [
Expand Down Expand Up @@ -158,4 +162,6 @@ suite("test_timing_refresh_catalog", "p0,external,doris,external_docker,external
sql """drop catalog if exists test_timing_refresh_catalog1 """
sql """drop catalog if exists test_timing_refresh_catalog2 """
sql """drop database if exists internal.external_timing_refresh_catalog """

try_sql """drop user ${jdbcUser}"""
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,16 @@
suite("test_upgrade_lower_case_catalog_prepare", "p0,external,doris,external_docker,external_docker_doris") {

String jdbcUrl = context.config.jdbcUrl
String jdbcUser = context.config.jdbcUser
String jdbcPassword = context.config.jdbcPassword
String jdbcUser = "test_upgrade_lower_case_catalog_user"
String jdbcPassword = "C123_567p"
String s3_endpoint = getS3Endpoint()
String bucket = getS3BucketName()
String driver_url = "https://${bucket}.${s3_endpoint}/regression/jdbc_driver/mysql-connector-j-8.3.0.jar"

try_sql """drop user ${jdbcUser}"""
sql """create user ${jdbcUser} identified by '${jdbcPassword}'"""
sql """grant all on *.*.* to ${jdbcUser}"""

sql """drop database if exists internal.upgrade_lower_case_catalog_lower; """
sql """drop database if exists internal.upgrade_lower_case_catalog_UPPER; """
sql """create database if not exists internal.upgrade_lower_case_catalog_lower; """
Expand Down

0 comments on commit e9921d7

Please sign in to comment.