Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-11276

Mulltiple Insert into Federated Table Select From local Table

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Duplicate
    • 10.1.18
    • N/A
    • None
    • Windows 2012 R2 x2
      MariaDB 10.1.18 x2

    Description

      I have 2 sites, and there is the same database and tables at each site.
      I use event to call the procedure that will insert into federated table select from local table from one site, but there is only this error message "ERROR 1296 (HY000): Got error 10000 'Error on remote system: 2006: MySQL server has gone away' from FEDERATED"
      And I ran the procedure in cmd, there is also this message for this procedure, but sometime there is error message and the data seem ok to inserted into foreign tables.
      What can I do for this case?

      Attachments

        Issue Links

          Activity

            That's right. Consider the following example (it's more or less the same as the test in MDEV-4452 does, but I'm intentionally convert it into a manual test with two separate servers, to make it more obvious.

            On server 1 (remote server): create a remote table

            create table t_remote (a int primary key, b varchar(8));
            

            On server 2 (local server): create a federated table:

            create table t_local (a int primary key, b varchar(8)) 
              engine=federated connection='mysql://root@127.0.0.1:3307/test/t_remote';
            

            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):

            MariaDB [test]> show processlist;
            +----+------+-----------------+------+---------+------+-------+------------------+----------+
            | Id | User | Host            | db   | Command | Time | State | Info             | Progress |
            +----+------+-----------------+------+---------+------+-------+------------------+----------+
            |  3 | root | localhost:44325 | test | Query   |    0 | init  | show processlist |    0.000 |
            +----+------+-----------------+------+---------+------+-------+------------------+----------+
            1 row in set (0.00 sec)
            

            Now, set the timeout to a small value on the server 1 (the remote server):

            set global wait_timeout = 20;
            

            Select from the federated table on the local server:

            MariaDB [test]> select * from t_local;
            Empty set (0.00 sec)
            

            While 20 seconds have not passed, check the processlist on the remote server:

            MariaDB [test]> show processlist;
            +----+------+-----------------+------+---------+------+-------+------------------+----------+
            | Id | User | Host            | db   | Command | Time | State | Info             | Progress |
            +----+------+-----------------+------+---------+------+-------+------------------+----------+
            |  3 | root | localhost:44325 | test | Query   |    0 | init  | show processlist |    0.000 |
            |  7 | root | localhost:55683 | test | Sleep   |    3 |       | NULL             |    0.000 |
            +----+------+-----------------+------+---------+------+-------+------------------+----------+
            2 rows in set (0.00 sec)
            

            As you can see, we now have another connection, it's the connection from Federated.
            If you keep running SHOW PROCESSLIST, you'll see how the Time value grows:

            MariaDB [test]> show processlist;
            +----+------+-----------------+------+---------+------+-------+------------------+----------+
            | Id | User | Host            | db   | Command | Time | State | Info             | Progress |
            +----+------+-----------------+------+---------+------+-------+------------------+----------+
            |  3 | root | localhost:44325 | test | Query   |    0 | init  | show processlist |    0.000 |
            |  7 | root | localhost:55683 | test | Sleep   |   15 |       | NULL             |    0.000 |
            +----+------+-----------------+------+---------+------+-------+------------------+----------+
            2 rows in set (0.00 sec)
            

            But as soon as it exceeds the configured 20 seconds, the connection will disappear:

            MariaDB [test]> show processlist;
            +----+------+-----------------+------+---------+------+-------+------------------+----------+
            | Id | User | Host            | db   | Command | Time | State | Info             | Progress |
            +----+------+-----------------+------+---------+------+-------+------------------+----------+
            |  3 | root | localhost:44325 | test | Query   |    0 | init  | show processlist |    0.000 |
            +----+------+-----------------+------+---------+------+-------+------------------+----------+
            1 row in set (0.00 sec)
            

            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:

            MariaDB [test]> select * from t_local;
            ERROR 1158 (08S01): Got an error reading communication packets
            

            That's what bug MDEV-4452 is about.

            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.

            elenst Elena Stepanova added a comment - That's right. Consider the following example (it's more or less the same as the test in MDEV-4452 does, but I'm intentionally convert it into a manual test with two separate servers, to make it more obvious. On server 1 (remote server): create a remote table create table t_remote (a int primary key , b varchar (8)); On server 2 (local server): create a federated table: create table t_local (a int primary key , b varchar (8)) engine=federated connection = 'mysql://root@127.0.0.1:3307/test/t_remote' ; 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): MariaDB [test]> show processlist; + ----+------+-----------------+------+---------+------+-------+------------------+----------+ | Id | User | Host | db | Command | Time | State | Info | Progress | + ----+------+-----------------+------+---------+------+-------+------------------+----------+ | 3 | root | localhost:44325 | test | Query | 0 | init | show processlist | 0.000 | + ----+------+-----------------+------+---------+------+-------+------------------+----------+ 1 row in set (0.00 sec) Now, set the timeout to a small value on the server 1 (the remote server): set global wait_timeout = 20; Select from the federated table on the local server: MariaDB [test]> select * from t_local; Empty set (0.00 sec) While 20 seconds have not passed, check the processlist on the remote server: MariaDB [test]> show processlist; + ----+------+-----------------+------+---------+------+-------+------------------+----------+ | Id | User | Host | db | Command | Time | State | Info | Progress | + ----+------+-----------------+------+---------+------+-------+------------------+----------+ | 3 | root | localhost:44325 | test | Query | 0 | init | show processlist | 0.000 | | 7 | root | localhost:55683 | test | Sleep | 3 | | NULL | 0.000 | + ----+------+-----------------+------+---------+------+-------+------------------+----------+ 2 rows in set (0.00 sec) As you can see, we now have another connection, it's the connection from Federated. If you keep running SHOW PROCESSLIST , you'll see how the Time value grows: MariaDB [test]> show processlist; + ----+------+-----------------+------+---------+------+-------+------------------+----------+ | Id | User | Host | db | Command | Time | State | Info | Progress | + ----+------+-----------------+------+---------+------+-------+------------------+----------+ | 3 | root | localhost:44325 | test | Query | 0 | init | show processlist | 0.000 | | 7 | root | localhost:55683 | test | Sleep | 15 | | NULL | 0.000 | + ----+------+-----------------+------+---------+------+-------+------------------+----------+ 2 rows in set (0.00 sec) But as soon as it exceeds the configured 20 seconds, the connection will disappear: MariaDB [test]> show processlist; + ----+------+-----------------+------+---------+------+-------+------------------+----------+ | Id | User | Host | db | Command | Time | State | Info | Progress | + ----+------+-----------------+------+---------+------+-------+------------------+----------+ | 3 | root | localhost:44325 | test | Query | 0 | init | show processlist | 0.000 | + ----+------+-----------------+------+---------+------+-------+------------------+----------+ 1 row in set (0.00 sec) 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: MariaDB [test]> select * from t_local; ERROR 1158 (08S01): Got an error reading communication packets That's what bug MDEV-4452 is about. 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 .
            sujunmin Su, Jun-Ming added a comment - - edited

            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?

            sujunmin Su, Jun-Ming added a comment - - edited 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?

            Yes, I suppose it should work too.

            elenst Elena Stepanova added a comment - Yes, I suppose it should work too.
            sujunmin Su, Jun-Ming added a comment - - edited

            Thanks, it works now. Please close this issue.

            sujunmin Su, Jun-Ming added a comment - - edited Thanks, it works now. Please close this issue.

            Closing as a duplicate of MDEV-4452

            elenst Elena Stepanova added a comment - Closing as a duplicate of MDEV-4452

            People

              Unassigned Unassigned
              sujunmin Su, Jun-Ming
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.