avalon566 / sharding-scaling

Apache License 2.0
10 stars 4 forks source link

How to coordinate shardingsphere and shardingscaling #34

Open avalon566 opened 4 years ago

avalon566 commented 4 years ago

ScalingProgress Model

class MigrateProgress {
    String   status;
    Interge delaySecond;
}
  1. Status, can be SYNCING, STOPPING, STOPPED, EXCEPTION_STOPPED
  2. DelaySecond, return the max delay datasource value.If in history data sync stage, it will return Interge.MAX_VALUE.

How to calculate delay second

  1. Create a table with timestamp column in source datasource.
  2. Shardingscaling timing update the column with current timestamp.
  3. Read the column value from log, use current timestamp subtract the value, result is the delay second.

The solution references pt-heartbeat.

How to coordinate shardingsphere and shardingscaling

  1. If the status equals SYNCING, and the delaySecond less than threshold, we can switch shardingsphere to readonly mode, then send STOP command to shardingscaling.
  2. If the status equals STOPPED, we can swith shardingsphere configuration.
  3. If the status equals EXCEPTION_STOPPED, below operation need to cancal.
KomachiSion commented 4 years ago

I has some questions for this issue.

  1. For status, Should we split SYNCING to HISTORY and REALTIME?
  2. For status, Should we add STARTING or PREPARING?
  3. For delay second, it's used realtime only? Or both history and realtime?
avalon566 commented 4 years ago
  1. Personally, I think user don't concern about is history or realtime data sync stage, they only concern when to switch.
  2. This depending on the sumbit job behavior, If submit job then start immediately, I think it's not necessary.
  3. Both, in history data sync stage will return Interge.MAX_VALUE.
KomachiSion commented 4 years ago

I think we should show HISTORY status and REALTIME status, because uses can know which process the scaling job is in. Same reason for delay second, in history data sync stage will return Interge.MAX_VALUE is unfriendly. we can count before task start and record the current rows have been migrate.

avalon566 commented 4 years ago

How about provider two interface? one for shardingsphere, another for admin user. Their concerns are different. For admin user, not only max delay datanode value, need return all.

KomachiSion commented 4 years ago

The process information should be collected and saved fully, but users can judge which informations need to use.

the admin user or UI controller, need to show detail information, ShardingSphere program may only need the final status.

avalon566 commented 4 years ago

This issue only talk about when and how to switch with sharding-jdbc and sharding-proxy. UI and admin will be design and discuss in new issues.

KomachiSion commented 4 years ago

This issue only talk about when and how to switch with sharding-jdbc and sharding-proxy. UI and admin will be design and discuss in new issues.

OK, if only sharding-jdbc and sharding-proxy, the final status should be enough.