大家好,有空的可以帮我测试一下,你的mysql+starRocks有类似问题没,谢谢。
以下是我的相关测试步骤。
一、1fe+1be上的 jdbc_catalog
StarRocks > show catalogs;
±------------------------------±---------±-----------------------------------------------------------------+
| Catalog | Type | Comment |
±------------------------------±---------±-----------------------------------------------------------------+
| default_catalog | Internal | An internal catalog contains this cluster’s self-managed tables. |
| jdbc_192_168_5_18_3306_mysql8 | Jdbc | NULL |
±------------------------------±---------±-----------------------------------------------------------------+
2 rows in set (0.00 sec)
StarRocks > show create catalog jdbc_192_168_5_18_3306_mysql8;
±------------------------------±-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Catalog | Create Catalog |
±------------------------------±-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| jdbc_192_168_5_18_3306_mysql8 | CREATE EXTERNAL CATALOG jdbc_192_168_5_18_3306_mysql8
PROPERTIES (“driver_class” = “com.mysql.cj.jdbc.Driver”,
“checksum” = “ad7ef879830dbf17c7a73bf03b34f6fc”,
“driver_url” = “https://repo1.maven.org/maven2/mysql/mysql-connector-java/8.0.30/mysql-connector-java-8.0.30.jar”,
“type” = “jdbc”,
“user” = “root”,
“jdbc_uri” = “jdbc:mysql://192.168.5.18:3306”
) |
±------------------------------±-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
StarRocks >
二、mysql上的物理表和视图,最简单的视图
StarRocks > SELECT * FROM jdbc_192_168_5_18_3306_mysql8.test.some_info;
±------±-------±-----+
| sm_id | name | age |
±------±-------±-----+
| 1 | 张三 | 20 |
| 2 | 李四 | 30 |
±------±-------±-----+
2 rows in set (0.28 sec)
StarRocks > SELECT * FROM jdbc_192_168_5_18_3306_mysql8.test.view_some_info;
±------±-------±-----+
| sm_id | name | age |
±------±-------±-----+
| 1 | 张三 | 20 |
| 2 | 李四 | 30 |
±------±-------±-----+
2 rows in set (0.02 sec)
StarRocks >
三、在 default_catalog 里创建物化视图
StarRocks > set catalog default_catalog;
Query OK, 0 rows affected (0.00 sec)
StarRocks > create database for_test;
Query OK, 0 rows affected (0.01 sec)
StarRocks > use for_test;
Database changed
StarRocks > CREATE MATERIALIZED VIEW default_catalog.for_test.view_test REFRESH ASYNC EVERY(INTERVAL 2 MINUTE)
-> AS
-> SELECT sm_id
, name
FROM
-> ( SELECT sm_id
, name
FROM jdbc_192_168_5_18_3306_mysql8.test.view_some_info ) AS t;
Query OK, 0 rows affected (0.03 sec)
StarRocks >
StarRocks > show tables;
±-------------------+
| Tables_in_for_test |
±-------------------+
| view_test |
±-------------------+
1 row in set (0.00 sec)
StarRocks >
StarRocks > SELECT * FROM default_catalog.for_test.view_test;
±------±-------+
| sm_id | name |
±------±-------+
| 1 | 张三 |
| 2 | 李四 |
±------±-------+
2 rows in set (0.01 sec)
StarRocks >
四、测试出问题1,增加mysql物理表的数据行,再等2分钟自动同步后,在物化视图里的数据没有增加
StarRocks > SELECT * FROM jdbc_192_168_5_18_3306_mysql8.test.view_some_info;
±------±-------±-----+
| sm_id | name | age |
±------±-------±-----+
| 1 | 张三 | 20 |
| 2 | 李四 | 30 |
| 3 | 王五 | 40 |
±------±-------±-----+
3 rows in set (0.05 sec)
StarRocks >
StarRocks > SELECT * FROM view_test;
±------±-------+
| sm_id | name |
±------±-------+
| 2 | 李四 |
| 1 | 张三 |
±------±-------+
2 rows in set (0.00 sec)
StarRocks >
StarRocks > SHOW MATERIALIZED VIEWS FROM for_test WHERE NAME = ‘view_test’ \G
*************************** 1. row ***************************
id: 10526
database_name: for_test
name: view_test
refresh_type: ASYNC
is_active: true
inactive_reason:
partition_type: UNPARTITIONED
task_id: 10533
task_name: mv-10526
last_refresh_start_time: 2024-07-19 08:55:41
last_refresh_finished_time: 2024-07-19 08:55:41
last_refresh_duration: 0.033
last_refresh_state: SUCCESS
last_refresh_force_refresh: false
last_refresh_start_partition: NULL
last_refresh_end_partition: NULL
last_refresh_base_refresh_partitions: {}
last_refresh_mv_refresh_partitions: []
last_refresh_error_code: 0
last_refresh_error_message:
rows: 2
text: CREATE MATERIALIZED VIEW view_test
(sm_id
, name
)
DISTRIBUTED BY RANDOM
REFRESH ASYNC EVERY(INTERVAL 2 MINUTE)
PROPERTIES (
“replicated_storage” = “true”,
“replication_num” = “1”,
“storage_medium” = “HDD”
)
AS SELECT t
.sm_id
, t
.name
FROM (SELECT view_some_info
.sm_id
, view_some_info
.name
FROM jdbc_192_168_5_18_3306_mysql8
.test
.view_some_info
) t
;
extra_message: {“queryIds”:[“ad69864a-45ac-11ef-9000-bc2411a2a73b”],“isManual”:false,“isSync”:false,“isReplay”:false,“priority”:0,“lastTaskRunState”:“SUCCESS”}
query_rewrite_status: VALID
1 row in set (0.02 sec)
StarRocks >
StarRocks > SELECT * FROM view_test;
±------±-------+
| sm_id | name |
±------±-------+
| 1 | 张三 |
| 2 | 李四 |
±------±-------+
2 rows in set (0.01 sec)
StarRocks >
五,在上面 SHOW MATERIALIZED VIEWS ... 即使等几个2分钟,它都有显示 ASYNC=SUCCESS,但是物化视图的查询数据,依旧没有预期的与mysql同步。
六、测试出问题2,居然此时,查询mysql的视图数据,也没有更新为新的数据!!
StarRocks > SELECT sm_id
,name
FROM jdbc_192_168_5_18_3306_mysql8.test.view_some_info;
±------±-------+
| sm_id | name |
±------±-------+
| 2 | 李四 |
| 1 | 张三 |
±------±-------+
2 rows in set (0.03 sec)
StarRocks >
七,但此时查询mysql视图如果多1个字段,却有更新为新的数据!!
StarRocks > SELECT sm_id
,name
,age
FROM jdbc_192_168_5_18_3306_mysql8.test.view_some_info;
±------±-------±-----+
| sm_id | name | age |
±------±-------±-----+
| 1 | 张三 | 20 |
| 2 | 李四 | 30 |
| 3 | 王五 | 40 |
±------±-------±-----+
3 rows in set (0.04 sec)
StarRocks >
以上,麻烦有空的兄弟帮我,在你的系统里测试一下,有类似问题没,谢谢。