Description:
While configuring replication filters using "CHANGE REPLICATION FILTER" command, all global replication filters are copied to the channel specific filters by default initially. After a while once can consider to configure channel specific filters. At this stage, global specific filters are not applicable to mentioned channel and only filters defined for particular channel will be applicable. So far it can be considered as expected behavior (documented).
When we change the global filters in later stages, its replacing the channel specific filters.
How to repeat:
mysql> CHANGE REPLICATION FILTER REPLICATE_IGNORE_DB=(`globaldb`);
Query OK, 0 rows affected (0.00 sec)
mysql> select * from performance_schema.replication_applier_global_filters;
+---------------------+-------------+---------------------------+----------------------------+
| FILTER_NAME | FILTER_RULE | CONFIGURED_BY | ACTIVE_SINCE |
+---------------------+-------------+---------------------------+----------------------------+
| REPLICATE_IGNORE_DB | globaldb | CHANGE_REPLICATION_FILTER | 2023-07-28 16:17:56.833261 |
+---------------------+-------------+---------------------------+----------------------------+
1 row in set (0.00 sec)
mysql> select * from performance_schema.replication_applier_filters;
+--------------+---------------------+-------------+---------------------------+----------------------------+---------+
| CHANNEL_NAME | FILTER_NAME | FILTER_RULE | CONFIGURED_BY | ACTIVE_SINCE | COUNTER |
+--------------+---------------------+-------------+---------------------------+----------------------------+---------+
| | REPLICATE_IGNORE_DB | globaldb | CHANGE_REPLICATION_FILTER | 2023-07-28 16:17:56.833261 | 0 |
+--------------+---------------------+-------------+---------------------------+----------------------------+---------+
1 row in set (0.01 sec)
mysql> CHANGE REPLICATION FILTER REPLICATE_IGNORE_DB=(`channeldb`) for channel '';
Query OK, 0 rows affected (0.00 sec)
mysql> select * from performance_schema.replication_applier_global_filters;
+---------------------+-------------+---------------------------+----------------------------+
| FILTER_NAME | FILTER_RULE | CONFIGURED_BY | ACTIVE_SINCE |
+---------------------+-------------+---------------------------+----------------------------+
| REPLICATE_IGNORE_DB | globaldb | CHANGE_REPLICATION_FILTER | 2023-07-28 16:17:56.833261 |
+---------------------+-------------+---------------------------+----------------------------+
1 row in set (0.00 sec)
mysql> select * from performance_schema.replication_applier_filters;
+--------------+---------------------+-------------+---------------------------------------+----------------------------+---------+
| CHANNEL_NAME | FILTER_NAME | FILTER_RULE | CONFIGURED_BY | ACTIVE_SINCE | COUNTER |
+--------------+---------------------+-------------+---------------------------------------+----------------------------+---------+
| | REPLICATE_IGNORE_DB | channeldb | CHANGE_REPLICATION_FILTER_FOR_CHANNEL | 2023-07-28 16:19:10.127976 | 0 |
+--------------+---------------------+-------------+---------------------------------------+----------------------------+---------+
1 row in set (0.00 sec)
-- below command replace channel specific filters
mysql> CHANGE REPLICATION FILTER REPLICATE_IGNORE_DB=(`globaldb`,`globaldb123`);
Query OK, 0 rows affected (0.00 sec)
mysql> select * from performance_schema.replication_applier_filters;
+--------------+---------------------+----------------------+---------------------------+----------------------------+---------+
| CHANNEL_NAME | FILTER_NAME | FILTER_RULE | CONFIGURED_BY | ACTIVE_SINCE | COUNTER |
+--------------+---------------------+----------------------+---------------------------+----------------------------+---------+
| | REPLICATE_IGNORE_DB | globaldb,globaldb123 | CHANGE_REPLICATION_FILTER | 2023-07-28 16:20:57.524803 | 0 |
+--------------+---------------------+----------------------+---------------------------+----------------------------+---------+
1 row in set (0.00 sec)
mysql> select * from performance_schema.replication_applier_global_filters;
+---------------------+----------------------+---------------------------+----------------------------+
| FILTER_NAME | FILTER_RULE | CONFIGURED_BY | ACTIVE_SINCE |
+---------------------+----------------------+---------------------------+----------------------------+
| REPLICATE_IGNORE_DB | globaldb,globaldb123 | CHANGE_REPLICATION_FILTER | 2023-07-28 16:20:57.524803 |
+---------------------+----------------------+---------------------------+----------------------------+
1 row in set (0.01 sec)
Suggested fix:
The global filters should be copied to any channel only if particular channel has no channel specific filters. The channel specific filters should not be replaced with global filter unless channel specific filters are explicitly reset.