shardingsphere icon indicating copy to clipboard operation
shardingsphere copied to clipboard

Using Add Resource causes loss of broadcast tables under the /metadata/schemaName/tables

Open ReyYang opened this issue 4 years ago • 3 comments

Which version of ShardingSphere did you use?

master batch

Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?

ShardingSphere-Proxy

Expected behavior

/metadata/schemaName/tables broadcast table metadata exist

Actual behavior

/metadata/schemaName/tables broadcast table metadata lost

Reason analyze (If you can)

It may be because Debug finds TableMetadataLoadRengine's LOAD method leads to the loss of the broadcast

Steps to reproduce the behavior, such as: SQL to execute, sharding rule configuration, when exception occur etc.

1、start ShardingSphere-proxy 2、perform distsql 3、Data loss found in ZK

ReyYang avatar Feb 21 '22 03:02 ReyYang

before perform distsql image after perform distsql image

ReyYang avatar Feb 21 '22 03:02 ReyYang

I tried these steps, but didn't reproduced.

FIREST

server.ymal

mode:
  type: Cluster
  repository:
    type: ZooKeeper
    props:
      namespace: agent
      server-lists: localhost:2181
      retryIntervalMilliseconds: 500
      timeToLiveSeconds: 60
      maxRetries: 3
      operationTimeoutMilliseconds: 30000
  overwrite: true
#
rules:
  - !AUTHORITY
    users:
      - root@%:root
      - sharding@:sharding
    provider:
      type: ALL_PRIVILEGES_PERMITTED

props:
  max-connections-size-per-query: 1
  executor-size: 16  # Infinite by default.
  proxy-frontend-flush-threshold: 128  # The default value is 128.
  proxy-opentracing-enabled: false
  proxy-hint-enabled: true
  sql-show: false
  check-table-metadata-enabled: false
  lock-wait-timeout-milliseconds: 50000 # The maximum time to wait for a lock
  show-process-list-enabled: true
  # Proxy backend query fetch size. A larger value may increase the memory usage of ShardingSphere Proxy.
  # The default value is -1, which means set the minimum value for different JDBC drivers.
  proxy-backend-query-fetch-size: -1
  check-duplicate-table-enabled: false

Second

CREATE DATABASE sharding_db;

Third

ADD RESOURCE demo_ds_0 (
    HOST=127.0.0.1,
    PORT=3306,
    DB=demo_ds_0,
    USER=root,
    PASSWORD=123456
), demo_ds_1(
    HOST=127.0.0.1,
    PORT=3306,
    DB=demo_ds_0,
    USER=root,
    PASSWORD=123456
);

Fourth

CREATE SHARDING BROADCAST TABLE RULES (t_config);

final

I found broadcast tables are exist. image

tuichenchuxin avatar Mar 30 '22 02:03 tuichenchuxin

Since there's no exact reproduct steps. I tried on master branch, commit 6fd57154632ea0f108f9e991b1721ad1c9660aed. On existing schema test1, execute SQLs:

mysql> CREATE SHARDING BROADCAST TABLE RULES (t_broadcast_table);
Query OK, 0 rows affected (0.42 sec)

mysql> CREATE TABLE t_broadcast_table (id INT NOT NULL, status VARCHAR(45) NULL, PRIMARY KEY (id));
Query OK, 0 rows affected (0.39 sec)

mysql> ALTER SHARDING TABLE RULE t_order(
    -> RESOURCES(ds_2,ds_3,ds_4),
    -> SHARDING_COLUMN=order_id,
    -> TYPE(NAME=hash_mod,PROPERTIES("sharding-count"=6)),
    -> KEY_GENERATE_STRATEGY(COLUMN=order_id,TYPE(NAME=snowflake,PROPERTIES("worker-id"=123)))
    -> ), t_order_item(
    -> RESOURCES(ds_2,ds_3,ds_4),
    -> SHARDING_COLUMN=order_id,
    -> TYPE(NAME=hash_mod,PROPERTIES("sharding-count"=6)),
    -> KEY_GENERATE_STRATEGY(COLUMN=order_id,TYPE(NAME=snowflake,PROPERTIES("worker-id"=123)))
    -> );
Query OK, 0 rows affected (0.26 sec)

t_broadcast_table always exist in registry center after created.

We'll check it again when developing broadcast table support of scaling job.

sandynz avatar Mar 30 '22 03:03 sandynz