[MDEV-11276] Mulltiple Insert into Federated Table Select From local Table Created: 2016-11-13 Updated: 2016-11-24 Resolved: 2016-11-24 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Storage Engine - Federated |
| Affects Version/s: | 10.1.18 |
| Fix Version/s: | N/A |
| Type: | Bug | Priority: | Major |
| Reporter: | Su, Jun-Ming | Assignee: | Unassigned |
| Resolution: | Duplicate | Votes: | 0 |
| Labels: | None | ||
| Environment: |
Windows 2012 R2 x2 |
||
| Issue Links: |
|
||||||||
| Description |
|
I have 2 sites, and there is the same database and tables at each site. |
| Comments |
| Comment by Elena Stepanova [ 2016-11-16 ] | ||||||||||||||||||||||||||||||||||||||
|
Communication between local and remote servers in Federated is subject to standard connection timeouts. See some more details in | ||||||||||||||||||||||||||||||||||||||
| Comment by Su, Jun-Ming [ 2016-11-17 ] | ||||||||||||||||||||||||||||||||||||||
|
Hi, thanks for your respond. I think it is not the problem for timeouts. Because the query execute use only one second to throw this error (almost instantly), and I use mysqldump and pipe to mysql to restore the same table use 3 mins (include table lock). original worked solution | ||||||||||||||||||||||||||||||||||||||
| Comment by Elena Stepanova [ 2016-11-17 ] | ||||||||||||||||||||||||||||||||||||||
|
We are not talking about query timeouts, but connection timeouts which happen when the connection is inactive, ones controlled by wait_timeout. That is, you establish the connection between local and remote server using a federated table; then you don't use the connection for more than wait_timeout seconds; during this time, the connection expires, but obviously you can't see it because you're not using it. Then you're trying to use it again by querying the table, and server informs you that the connection is gone. That's exactly why you're getting the error immediately, within a second, and why you're not getting it when you're doing the dump, because the connection stays busy and it doesn't expire. | ||||||||||||||||||||||||||||||||||||||
| Comment by Su, Jun-Ming [ 2016-11-17 ] | ||||||||||||||||||||||||||||||||||||||
|
Thanks for your response. This query is executed in an event, not by users. Is it still wait_time issue? What do I change this variable to? | ||||||||||||||||||||||||||||||||||||||
| Comment by Elena Stepanova [ 2016-11-17 ] | ||||||||||||||||||||||||||||||||||||||
|
Yes, wait_timeout is applied anyway. What to change the value to depends on your work flow. How long the connection can stay idle? Configure the value to be higher than the maximum expected idle time. | ||||||||||||||||||||||||||||||||||||||
| Comment by Su, Jun-Ming [ 2016-11-17 ] | ||||||||||||||||||||||||||||||||||||||
|
Thanks. I have checked the value, and it is default 28800. | ||||||||||||||||||||||||||||||||||||||
| Comment by Elena Stepanova [ 2016-11-17 ] | ||||||||||||||||||||||||||||||||||||||
|
Is it possible that there have been no use of the connection for over 8 hours before the problem occurs? | ||||||||||||||||||||||||||||||||||||||
| Comment by Su, Jun-Ming [ 2016-11-17 ] | ||||||||||||||||||||||||||||||||||||||
|
I think it is not possible. Because it is the query executed in a mariadb schedule event (every day at am 3:00) ,not by user client login and execute. | ||||||||||||||||||||||||||||||||||||||
| Comment by Elena Stepanova [ 2016-11-17 ] | ||||||||||||||||||||||||||||||||||||||
|
But if it's executed only once a day at the same time, it is certainly more than 8 hours between the queries, so it will definitely time out. What did you mean by "not possible"? | ||||||||||||||||||||||||||||||||||||||
| Comment by Su, Jun-Ming [ 2016-11-17 ] | ||||||||||||||||||||||||||||||||||||||
|
So you mean the connection you connect to federated table this time and next time is not longer than wait_timeout, if this time update federated table and next time update federated table difference more than wait_timeout, will throw this error, right? | ||||||||||||||||||||||||||||||||||||||
| Comment by Elena Stepanova [ 2016-11-17 ] | ||||||||||||||||||||||||||||||||||||||
|
That's right. Consider the following example (it's more or less the same as the test in On server 1 (remote server): create a remote table
On server 2 (local server): create a federated table:
So far you've just created tables, but did not use them, so there is no connection between the local and remote server. Check it by running show processlist on the server 1 (remote):
Now, set the timeout to a small value on the server 1 (the remote server):
Select from the federated table on the local server:
While 20 seconds have not passed, check the processlist on the remote server:
As you can see, we now have another connection, it's the connection from Federated.
But as soon as it exceeds the configured 20 seconds, the connection will disappear:
And now, if you run the query on the local server again, you'll get an error. It can be either "server has gone away" or "error reading communication packets" – all the same, it will fail:
That's what bug If you re-run the query, it will re-establish the connection, and the timeout will start count-down again. Absolute values does not matter. Even if you have the timeout 28800, but you only run the query once a day, you'll get the same problem. Try to set the timeout to more than a day and see if the problem goes away. Remember to set the GLOBAL value of wait_timeout. | ||||||||||||||||||||||||||||||||||||||
| Comment by Su, Jun-Ming [ 2016-11-17 ] | ||||||||||||||||||||||||||||||||||||||
|
Thanks, you help me a lot, maybe I can do another job (event) for query the federated table per 1 hour to prevent to remote server to drop the connection, right? | ||||||||||||||||||||||||||||||||||||||
| Comment by Elena Stepanova [ 2016-11-17 ] | ||||||||||||||||||||||||||||||||||||||
|
Yes, I suppose it should work too. | ||||||||||||||||||||||||||||||||||||||
| Comment by Su, Jun-Ming [ 2016-11-24 ] | ||||||||||||||||||||||||||||||||||||||
|
Thanks, it works now. Please close this issue. | ||||||||||||||||||||||||||||||||||||||
| Comment by Elena Stepanova [ 2016-11-24 ] | ||||||||||||||||||||||||||||||||||||||
|
Closing as a duplicate of |