-
Notifications
You must be signed in to change notification settings - Fork 173
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support bidirectional data replication between two TiDB clusters #251
Comments
@shenli |
can use docker-compose to start a TiDB cluster with binlog, can see https://github.com/pingcap/tidb-docker-compose, use docker-compose-binlog.yml this file, and need update drainer's config file to send binlog to kafka. |
@Ryan-Git are anything going well? |
@GregoryIan I've roughly finished the change. Need more time for testing. btw, there's no unique key info in the messages. It will cause some problems when writing to target in parallel. |
@Ryan-Git do you means find a bug when table without unique key in gravity? |
For mysql, we consider new and old values for both primary keys and unique keys as "data dependency". A message has duplicate dependency with ongoing ones will be delayed until they finished. It's just like lock/latch mechanism in databases. for example, there's one row with pk = 1 and uk = 1. Two transactions happen in following sequence delete from t where uk = 1;
insert into t(pk, uk) values (2, 1); They should be executed in sequence. But if we only know primary key, it's different(1 and 2). So gravity is allowed to output them in arbitrary order. |
can we get the schema from downstream? |
Getting the schema from downstream might work, but
One way to get around this is connecting to the source data store. But the message and schema may not match unless we keep a schema history. That's another story though(#174 ). I think add the unique key info in the messages is a better solution for TiDB. Temporally, we can set number of workers to one, handle the messages sequentially, just like drainer outputs to only one partition. But the throughput would be a problem. btw, do we need to support DDL? |
I think i can add the unique key info in the messages later. Is the DDL supported for other sources like mysql ? |
Yes, partially supported. |
@july2993 |
all column belong to PK will be mark as |
ok |
@july2993 |
the relate pr of drainer is not merged ye pingcap/tidb-binlog#858, I will merge it ASAP then you can use the added unique info, if only testing the old primary key flag i think you can just use the docker-compose privided first by @WangXiangUSTC |
@WangXiangUSTC
tidb: (I can't find config
|
@Ryan-Git diff --git a/config/drainer.toml b/config/drainer.toml
index b2190e3..bf4f064 100644
--- a/config/drainer.toml
+++ b/config/drainer.toml
@@ -40,7 +40,7 @@ txn-batch = 20
# to get higher throughput by higher concurrent write to the downstream
worker-count = 16
- disable-dispatch = false
+ # disable-dispatch = false
# safe mode will split update to delete and insert
safe-mode = false
diff --git a/config/tidb.toml b/config/tidb.toml
index 9f881b4..a7d3fc1 100644
--- a/config/tidb.toml
+++ b/config/tidb.toml
@@ -113,6 +113,8 @@ metrics-addr = "pushgateway:9091"
metrics-interval = 15
[performance]
+txn-total-size-limit = 104857599
+
# Max CPUs to use, 0 use number of CPUs in the machine.
max-procs = 0
# StmtCountLimit limits the max count of statement inside a transaction. |
@july2993 |
here is the total changed july2993/tidb-docker-compose@4fe618e Also, the newest version of TiDB-Binlog has included the added unique key info, you may need to re-pull.
after that, it 's expected to start all services as:
A example:
here I use the tool print to consume messages and just log it.
we can get message from Kafka:
the default topic name is _obinlog, you can change it by setting Let me know if there's anything more I can help. |
@july2993 Thanks. I'll try this. |
@july2993 btw, default value for |
Gravity could replicate data between two MySQL clusters bidirectionally and could read TiDB's binlog. So I guess it is not hard to support bidirectional data replication between two TiDB Clusters.
The text was updated successfully, but these errors were encountered: