Comments (7)
Ok, just read the docs, looks like replicate-do-db
and replicate-do-table
parameters must be passed from the library.
But currently the lib doesn't support it. I will try and see if I can easily add support for filtering
from mysqlcdc.
I think it's a bad idea to change binlog_do_db
parameter as it affects what is written in the server binlog
from mysqlcdc.
It looks like replicate-do-db
and replicate-do-table
parameters are used by the internal implementation of MySQL replica server when it replicates binary stream from the master.
So the only way to filter results(as I see it) is to filter events manually based on the DatabaseName
and TableName
from the TableMapEvent
. I wouldn't recommend changing binlog_do_db
because it will affect master-slave replication(the database slave will receive filtered events)
from mysqlcdc.
Hi,
The library doesn't filter results.
You need to configure filtering in the master server config file.
The documentation says that there is replicate-do-table
parameter although I've never configured filtering.
In my project I switched to PostgreSQL which has logical replication and allows you to select the tables that you want to replicate
from mysqlcdc.
Thank you!
Just to clarify:
From the documentation, the table map event is triggered automatically, so I will just need to catch that and map then filter based on the table Id or table name. Is that the correct flow?
from mysqlcdc.
Yes, in my docs I wrote this:
A typical transaction has the following structure.
GtidEvent
if gtid mode is enabled.- One or many
TableMapEvent
events.- One or many
WriteRowsEvent
events. - One or many
UpdateRowsEvent
events. - One or many
DeleteRowsEvent
events.
- One or many
XidEvent
indicating commit of the transaction.
So you will receive TableMapEvent
event first and then one or many change events associated with it.
You can then skip the events. Just wait for another TableMapEvent
.
You can write something like this:
var filterDatabaseName = "MyDatabase";
var filterTableName = "MyTable";
var ignoredTables = new HashSet<long>();
if (binlogEvent is TableMapEvent tableMap)
{
if(tableMap.DatabaseName != filterDatabaseName || tableMap.TableName != filterTableName)
{
ignoredTables.Add(tableMap.TableId);
}
}
else if (binlogEvent is WriteRowsEvent writeRows)
{
if(!ignoredTables.Contains(writeRows.TableId))
{
await HandleWriteRowsEvent(writeRows);
}
}
else if (binlogEvent is UpdateRowsEvent updateRows)
{
if(!ignoredTables.Contains(updateRows.TableId))
{
await HandleUpdateRowsEvent(updateRows);
}
}
else if (binlogEvent is DeleteRowsEvent deleteRows)
{
if(!ignoredTables.Contains(deleteRows.TableId))
{
await HandleDeleteRowsEvent(deleteRows);
}
}
In PostgreSQL the filtering is done easier. You just create a slot on the master server and tell it to send your code only the changes you want while the database replication continues to work properly from a different event stream.
from mysqlcdc.
from mysqlcdc.
Related Issues (20)
- support for binlog-do-db/binlog-ignore-db HOT 6
- There is a question about missing transactions HOT 13
- How to get the cells column name? HOT 8
- hope to support semi-sync-replication HOT 4
- MaxScale BinLog Server compatibility like maxwell discussion HOT 1
- Empty VARCHAR data column value and JSON data column inner string field value is parsed as null out of MySQL binlog. HOT 12
- Implement v2.0
- no UpdateRowsEvent\DeleteRowsEvent only QueryEvent HOT 2
- [Question] TableMapEvent.TableMetaData.ColumnNames returns null HOT 7
- update row event,but ColumnsPresentBeforeUpdate and ColumnsPresentAfterUpdate is same ? HOT 2
- Could not receive a master heartbeat within the specified interval HOT 3
- binlog_row_metadata existence HOT 1
- Add support for USER_VAR_EVENT
- TableMetadata.ColumnNames is null HOT 2
- can't find TableId from INFORMATION_SCHEMA.TABLES. HOT 2
- Support Event To Detect Column Changes For Mysql:5.7 HOT 7
- Parsing opaque values in JSON
- Implement SSL strategies HOT 3
- use Production Environment HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mysqlcdc.