0

When I execute the following command for creating shard :

 mysqlfabric sharding add_table 1 employees.employees emp_no

I get the following error:

DatabaseError: Command (INSERT INTO shard_tables(shard_mapping_id, table_name, column_name) VALUES(%s, %s, %s), ('1', 'employees.employees', 'emp_no')) failed accessing (localhost:3306). 1452 (23000): Cannot add or update a child row: a foreign key constraint fails (fabric.shard_tables, CONSTRAINT fk_shard_mapping_id FOREIGN KEY (shard_mapping_id) REFERENCES shard_maps (shard_mapping_id)).

I also tried using SET FOREIGN_KEY_CHECKS = 0; but it doesnot solve the problem.

I am using MySQL Fabric

My Fabric.cfg

[DEFAULT]
prefix =
sysconfdir = /etc
logdir = /var/log

[statistics]
prune_time = 3600

[logging]
url = file:///var/log/fabric.log
level = INFO

[storage]
database = fabric
user = fabric
address = 192.168.1.96:3306
connection_delay = 1
connection_timeout = 6
password =
connection_attempts = 6

[connector]
ttl = 1

[protocol.xmlrpc]
threads = 5
address = 192.168.1.96:32274




[servers]
restore_user = fabric
unreachable_timeout = 5
backup_password =
backup_user = fabric
user = fabric
restore_password =
password =


[executor]
executors = 5

[sharding]
mysqldump_program = /home/mysql/mysql/bin/mysqldump
mysqlclient_program = /home/mysql/mysql/bin/mysql

[protocol.mysql]
disable_authentication = no
ssl_cert =
ssl_key =
ssl_ca =
user = admin
address = localhost:32275
password =
reza.cse08
  • 5,938
  • 48
  • 39

1 Answers1

0

Oh, I solved it. In the following command :

mysqlfabric sharding add_table 1 employees.employees emp_no

I was using "1" which shows the MAPPING SHARD ID IN fabric.shard_maps table and is not present there so I chose one of the mapping id present there for my_shard.

Thank You!!