Skip to content

Conversation

LemonCL
Copy link

@LemonCL LemonCL commented Sep 1, 2025

功能概述

本PR为CCR Syncer添加了集群级别同步功能和动态监控间隔配置功能。

主要更改

  1. 集群级CCR同步 - 支持一键同步整个集群的所有数据库
  2. 动态监控间隔配置 - 支持运行时调整数据库监控频率

新增API端点

  • POST /update_monitor_interval - 更新监控间隔
  • GET /get_monitor_interval - 获取当前监控间隔

向后兼容性

  • 完全保持现有功能不变
  • 新参数 cluster_sync 默认为 false

1. 集群级别CCR同步

  • 自动发现源集群中的所有数据库
  • 为每个数据库创建独立的同步任务
  • 动态监控数据库的新增和删除
  • 自动创建/删除对应的同步任务

2. 动态监控间隔配置

  • 运行时调整数据库监控频率
  • 无需重启服务即可生效
  • 线程安全的配置更新

API 接口

创建集群级同步任务

接口: POST /create_ccr

请求参数:

{
  "name": "cluster_sync_job",
  "src": {
    "host": "source-cluster-host",
    "port": 9030,
    "user": "root",
    "password": "password",
    "database": ""
  },
  "dest": {
    "host": "dest-cluster-host",
    "port": 9030,
    "user": "root", 
    "password": "password",
    "database": ""
  },
  "cluster_sync": true
}

参数说明:

  • cluster_sync: 设置为 true 启用集群级同步
  • name: 同步任务的基础名称,实际任务名会加上数据库名后缀
  • src/dest: 源集群和目标集群的连接信息
  • 其他参数与单数据库同步相同

响应示例:

{
  "success": true
}

更新监控间隔

接口: POST /update_monitor_interval

请求参数:

{
  "interval_seconds": 300
}

参数说明:

  • interval_seconds: 监控间隔时间(秒),必须大于0

响应示例:

{
  "success": true
}

获取当前监控间隔

接口: GET /get_monitor_interval

响应示例:

{
  "success": true,
  "interval_seconds": 120
}

w41ter and others added 30 commits January 9, 2025 17:02
w41ter and others added 13 commits May 13, 2025 16:12
…ration

This commit introduces cluster-level CCR synchronization functionality and dynamic monitor interval configuration capabilities.

1. **Cluster-level CCR Sync**
   - Add `ClusterSync` parameter to `CreateCcrRequest`
   - Implement `createClusterCcr()` function for cluster-wide database sync
   - Add automatic database monitoring with `startDatabaseMonitor()`
   - Support dynamic detection of new/deleted databases
   - Auto-create/remove sync tasks for database changes

2. **Dynamic Monitor Interval Configuration**
   - Add `/update_monitor_interval` HTTP endpoint
   - Add `/get_monitor_interval` HTTP endpoint
   - Support runtime modification of database monitoring frequency
   - Implement thread-safe interval updates using channels

- `POST /update_monitor_interval` - Update monitoring interval
- `GET /get_monitor_interval` - Get current monitoring interval

- All existing single-database sync functionality remains unchanged
- New `cluster_sync` parameter defaults to `false`

- Thread-safe implementation using `sync.RWMutex`
- Non-blocking channel communication for interval updates
- Comprehensive error handling and retry mechanisms
- Detailed logging for observability
feat: Add cluster-level CCR sync and dynamic monitor interval configuration

This commit introduces cluster-level CCR synchronization functionality and dynamic monitor interval configuration capabilities.

1. **Cluster-level CCR Sync**
   - Add `ClusterSync` parameter to `CreateCcrRequest`
   - Implement `createClusterCcr()` function for cluster-wide database sync
   - Add automatic database monitoring with `startDatabaseMonitor()`
   - Support dynamic detection of new/deleted databases
   - Auto-create/remove sync tasks for database changes

2. **Dynamic Monitor Interval Configuration**
   - Add `/update_monitor_interval` HTTP endpoint
   - Add `/get_monitor_interval` HTTP endpoint
   - Support runtime modification of database monitoring frequency
   - Implement thread-safe interval updates using channels

3. **Performance Optimizations**
   - Optimize lock usage in `startDatabaseMonitor()`
   - Replace frequent lock operations with channel communication
   - Reduce lock contention and improve monitoring performance

- `POST /update_monitor_interval` - Update monitoring interval
- `GET /get_monitor_interval` - Get current monitoring interval

- All existing single-database sync functionality remains unchanged
- New `cluster_sync` parameter defaults to `false`

- Thread-safe implementation using `sync.RWMutex`
- Non-blocking channel communication for interval updates
- Comprehensive error handling and retry mechanisms
- Detailed logging for observability

Closes: #[issue_number]

docs: Add documentation for cluster CCR sync feature
@LemonCL LemonCL changed the base branch from branch-3.0 to master September 1, 2025 09:26
@LemonCL LemonCL changed the base branch from master to dev September 1, 2025 09:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants