Find Jobs
Hire Freelancers

MySQL Trigger insert into federated table, handle lost connection

$10-30 USD

Dibatalkan
Disiarkan lebih dari 4 tahun yang lalu

$10-30 USD

Dibayar semasa penghantaran
I have the following problem: Local server writes into table 'test' and makes a copy with trigger into federated table 'test_link'. Everything works when there is connection between the two servers. When the connection is lost I get table lock on 'test' and the local server gets overloaded in few minutes. When the connection is working: mysql> SELECT * FROM [login to view URL] WHERE TABLE_NAME = 'test_link' \G *************************** 1. row *************************** TABLE_CATALOG: def TABLE_SCHEMA: db_name TABLE_NAME: test_link TABLE_TYPE: BASE TABLE ENGINE: FEDERATED VERSION: 10 ROW_FORMAT: Dynamic TABLE_ROWS: 859883 AVG_ROW_LENGTH: 28 DATA_LENGTH: 24076724 MAX_DATA_LENGTH: 0 INDEX_LENGTH: 0 DATA_FREE: 0 AUTO_INCREMENT: 0 CREATE_TIME: NULL UPDATE_TIME: 1970-01-01 02:33:40 CHECK_TIME: 1970-01-01 02:33:40 TABLE_COLLATION: latin1_swedish_ci CHECKSUM: NULL CREATE_OPTIONS: TABLE_COMMENT: 1 row in set (0.27 sec) When the connection goes offline mysql> SELECT * FROM [login to view URL] WHERE TABLE_NAME = 'test_link' \G *************************** 1. row *************************** TABLE_CATALOG: def TABLE_SCHEMA: db_name TABLE_NAME: test_link TABLE_TYPE: BASE TABLE ENGINE: FEDERATED VERSION: 10 ROW_FORMAT: TABLE_ROWS: NULL AVG_ROW_LENGTH: 0 DATA_LENGTH: 0 MAX_DATA_LENGTH: 0 INDEX_LENGTH: 0 DATA_FREE: 0 AUTO_INCREMENT: NULL CREATE_TIME: NULL UPDATE_TIME: NULL CHECK_TIME: NULL TABLE_COLLATION: latin1_swedish_ci CHECKSUM: NULL CREATE_OPTIONS: TABLE_COMMENT: : 2003 : Can't connect to MySQL server on '[login to view URL]' (10061) 1 row in set, 1 warning (2.22 sec) From here I get that if I put in the trigger: SELECT ROW_FORMAT INTO @remote_connection FROM [login to view URL] WHERE TABLE_NAME = 'test_link'; IF @remote_connection = 'Dynamic' THEN INSERT INTO test_link; END IF; It should not attempt to insert data into federated table, when there is no connection. The query from terminal takes about 2 seconds to get that there is no connection (TABLE_ROWS: NULL). mysql> show processlist; | 2496 | user | [login to view URL] | db_name | Execute | 16 | Opening tables | SELECT ROW_FORMAT INTO @remote_connection FROM [login to view URL] WHERE TABLE_NAME = 'test_link' | and the time (16 sec) will continue to increase, keeping table 'test' locked. The trigger: DROP TRIGGER IF EXISTS `db_name`.`test_link`; DELIMITER $$ USE `db_name`$$ CREATE DEFINER=`user`@`%` TRIGGER `db_name`.`test_link` AFTER INSERT ON `db_name`.`test` FOR EACH ROW BEGIN SET @remote_connection=0; SELECT ROW_FORMAT INTO @remote_connection FROM [login to view URL] WHERE TABLE_NAME = 'test_link'; IF @remote_connection = 'Dynamic' THEN INSERT INTO `test_link` VALUES(null,'123'); END IF; END$$ To simplify the example, tables test and test link have two columns auto_increment data I'm looking for simple and reliable solution, to handle lost connection between the servers.
ID Projek: 23259260

Tentang projek

2 cadangan
Projek jarak jauh
Aktif 4 tahun yang lalu

Ingin menjana wang?

Faedah membida di Freelancer

Tetapkan bajet dan garis masa anda
Dapatkan bayaran untuk kerja anda
Tuliskan cadangan anda
Ianya percuma untuk mendaftar dan membida pekerjaan
2 pekerja bebas membida secara purata $50 USD untuk pekerjaan ini
Avatar Pengguna
Hello, I'm interested in your project. Please send me a message so that we can discuss more. I prefer to submit my detailed proposal after our discussion. Note: + We are flexible with changes. + https://www.freelancer.com/u/arjun366333 - My Profile link + We also provide post-implementation application support & maintenance Thanks, Regards Kanta Singh.
$70 USD dalam 7 hari
4.8 (10 ulasan)
5.1
5.1
Avatar Pengguna
Hello There, I have rich experience in working with these kind of problems. I can solve this problem. message me for more details. We can discuss more over chat.
$30 USD dalam 2 hari
4.7 (16 ulasan)
4.0
4.0

Tentang klien

Bendera UNITED KINGDOM
WATFORD, United Kingdom
5.0
18
Kaedah pembayaran disahkan
Ahli sejak Ogo 3, 2011

Pengesahan Klien

Terima kasih! Kami telah menghantar pautan melalui e-mel kepada anda untuk menuntut kredit percuma anda.
Sesuatu telah berlaku semasa menghantar e-mel anda. Sila cuba lagi.
Pengguna Berdaftar Jumlah Pekerjaan Disiarkan
Freelancer ® is a registered Trademark of Freelancer Technology Pty Limited (ACN 142 189 759)
Copyright © 2024 Freelancer Technology Pty Limited (ACN 142 189 759)
Memuatkan pratonton
Kebenaran diberikan untuk Geolocation.
Sesi log masuk anda telah luput dan telah dilog keluar. Sila log masuk sekali lagi.