Does adding a filter rule in DM require restarting the task? Can it be added online?

Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.

Original topic: DM增加一个过滤规则需要重启任务吗?可以在线增加吗?

| username: 舞动梦灵

After DM is deployed, when using gh-ost to add an index online on a remote MySQL, synchronization fails. According to the documentation, you can add the parameter online-ddl, which will convert gh-ost operations into create index. I want to add this parameter and then add a filter to exclude create index. Can this parameter be added online?

online-ddl: true
sql-pattern: [“^CREATE\s+DEFINER”, “^DROP\s+EVENT”, “^CREATE\s+INDEX”]

| username: 有猫万事足 | Original post link

This is the modification to the task. It cannot be added online.

However, when you stop the task, the binlog position recorded in dm_meta is still there.
So for the same task, you can stop the task, make the modifications, and then start the task again.
If the task name remains unchanged, it should continue to sync.
This is equivalent to starting the sync from the binlog position recorded in dm_meta.

| username: 哈喽沃德 | Original post link

No need to restart.

| username: 舞动梦灵 | Original post link

In my task-name, the binlog is already specified for a certain time. If it stops at the start, won’t it start syncing from the specified date, causing duplication? According to you, it will start from the recorded position. So, what if I delete the binlog information in the task? Will it automatically find and sync from dm_meta?

| username: 舞动梦灵 | Original post link

So how to change it? No need to restart. The DM version is 5.3.0.

| username: 有猫万事足 | Original post link

Yes, that’s what I mean.

| username: 舞动梦灵 | Original post link

Will this method work for me? Export the configuration, modify it, and then import it.

| username: TIDB-Learner | Original post link

Many tools have not been personally used.

| username: 有猫万事足 | Original post link

I haven’t tried it, but this approach imports and exports the data source together. I feel the operation might be even more significant than the one mentioned above.

What are you concerned about? Are you worried about long downtime for DM? Data inconsistency?

Even when using DM OpenAPI to update tasks, there are still the following considerations.

Note

When updating the synchronization task configuration, you must ensure that the task is in a paused state, has reached the incremental synchronization stage, and only certain fields can be updated.

| username: 舞动梦灵 | Original post link

I’m afraid that updating will resynchronize the previously written pos’ value, or that stopping and then starting might cause data loss. It has already been stopped twice recently, affecting business twice. :joy: There are no issues within three minutes. According to what you said, stopping and then starting might cause data loss.

| username: 有猫万事足 | Original post link

The content in the dm_meta database will remain unchanged. As long as you do not forcibly specify the binlog position in the task configuration, you do not need to worry about this.

| username: 舞动梦灵 | Original post link

If it was originally there and you don’t modify it, there shouldn’t be any problem. Or should you delete these two lines?

| username: 有猫万事足 | Original post link

To be on the safe side, delete it. All task configurations on my side are for full synchronization.
Without deleting the metadata table corresponding to the task in the dm_meta database, restarting the task will start from the incremental position where it was stopped. It will not go through the full synchronization process again.
I haven’t tried incremental, but I feel you don’t need to specify it.

| username: 舞动梦灵 | Original post link

My current setup is already specified. The original DM has crashed, and a new setup has been built on a new server. It is specified to start from the binlog and pos values where the previous DM crashed. According to your suggestion, if I stop it, should I delete the specified values? Or should I leave them as is? I feel like they need to be deleted.

| username: 有猫万事足 | Original post link

What you wrote is very difficult for me to understand.

The original DM has already crashed, and a new setup was built on the new server.

Did the DM-worker crash, and you expanded with a new worker? Or did you directly establish a new DM cluster, changing everything from master to worker?

| username: 舞动梦灵 | Original post link

Previously, the dm-worker crashed, and the old version was 1.0.6, which couldn’t be fixed. A new set of servers was installed with DM version 5.3, including new master and worker. In the task configuration, the binlog and pos values from the time of the previous crash were added:

- source-id: "db31"
  block-allow-list: "bw-rule-1"
  filter-rules: ["filter1"]
  meta:
    binlog-name: "mysql-db31-bin.019590"
    binlog-pos: 436561655
| username: 有猫万事足 | Original post link

Check if there is a {taskname}_syncer_checkpoint table under dm_meta. Open it and see if there are records similar to the ones above.

If there are, you don’t need to specify the binlog position in the task configuration.
If not, then you need to.

| username: 舞动梦灵 | Original post link

There are several tables with binlog information corresponding to the task name. So, does “not needed” mean that I should delete the previously written binlog information if I want it to start successfully? I’ll deploy another test setup to try it out.

| username: 有猫万事足 | Original post link

Then it’s not necessary. Anyway, my configuration has always been full updates. As long as these tables are still there, stopping the task and then starting it again won’t cause it to start from full synchronization; it will start from incremental synchronization.

| username: 舞动梦灵 | Original post link

Okay. Mine is not full, so it’s hard to estimate. Based on yours, I definitely need to delete the binlog information configuration after stop.
I’ll try both solutions.
One is to modify the configuration file. Stop and then start.
The other is an export and import. I’ll try both and see the effects.
Thanks, brother.