akopytov / sysbench

Scriptable database and system performance benchmark
GNU General Public License v2.0
6.06k stars 1.08k forks source link

Testsuite api_sql_mysql.t failed with Error "FATAL: unable to connect to MySQL server on host 'non-existing', port 3306, aborting..." #220

Closed rameshvs02 closed 6 years ago

rameshvs02 commented 6 years ago

Testsuite api_sql_mysql.t failed with Error "FATAL: unable to connect to MySQL server on host 'non-existing', port 3306, aborting..."

Is it expected error?

Error info

t/api_sql_mysql.t: failed
--- t/api_sql_mysql.t
+++ t/api_sql_mysql.t.err
@@ -67,9 +67,7 @@
   2
   --
   reconnects = 1
-  FATAL: unable to connect to MySQL server on host 'non-existing', port 3306, aborting...
-  FATAL: error 2005: Unknown MySQL server host 'non-existing' (0)
-  connection creation failed
+  <sql_connection>
   --
   FATAL: mysql_drv_query() returned error 1048 (Column 'a' cannot be null) for query 'INSERT INTO t VALUES (NULL)'
   Got an error descriptor:
rameshvs02 commented 6 years ago

ATtaching full error log. api_sql_mysql.t.txt

akopytov commented 6 years ago

It looks like a DNS lookup on your machine to a host named 'non-existing' succeeds. Some internet providers choose to resolve all DNS lookups to show a nice "Site doesn't exist" web page if the host cannot be resolved. In which case the test failure is expected, because its goal is specifically to test a connection failure to a non-existing host.

Can you confirm your DNS resolves non-existing to an IP address?

rameshvs02 commented 6 years ago

DNS is not resolving non-existing to an IP address

[vagrant@bkppgsql ~]$ host non-existing
Host non-existing not found: 3(NXDOMAIN)
[vagrant@bkppgsql ~]$
akopytov commented 6 years ago

What happens if you do mysql -h non-existing?

rameshvs02 commented 6 years ago
[vagrant@bkppgsql ~]$ mysql -uroot -hnon-existing
ERROR 2005 (HY000): Unknown MySQL server host 'non-existing' (0)
[vagrant@bkppgsql ~]$ mysql -hnon-existing
ERROR 2005 (HY000): Unknown MySQL server host 'non-existing' (0)
[vagrant@bkppgsql ~]$
akopytov commented 6 years ago

This is puzzling. And what happens if you run sysbench --mysql-host=non-existing ...?

rameshvs02 commented 6 years ago
[vagrant@bkppgsql ~]$ sysbench /usr/share/sysbench/oltp_insert.lua --mysql-host=non-existing --mysql-db=test --db-driver=mysql prepare
sysbench 1.0.14 (using bundled LuaJIT 2.1.0-beta2)

FATAL: unable to connect to MySQL server on host 'non-existing', port 3306, aborting...
FATAL: error 2005: Unknown MySQL server host 'non-existing' (0)
FATAL: `sysbench.cmdline.call_command' function failed: /usr/share/sysbench/oltp_common.lua:83: connection creation failed
[vagrant@bkppgsql ~]$
akopytov commented 6 years ago

Then I'm out of ideas. Is the test failure still reproducible? This is what the test does essentially:

cat > /tmp/test.lua <<EOF
function event()
  local drv = sysbench.sql.driver()
  local e,m = pcall(drv.connect, drv)
  print(m)
end
EOF

sysbench --events=1 --db-driver=mysql --mysql-host=non-existing /tmp/test.lua run
rameshvs02 commented 6 years ago

Yes, it is easy to reproduce.

[vagrant@bkppgsql ~]$ cat > /tmp/test.lua <<EOF
> function event()
>   local drv = sysbench.sql.driver()
>   local e,m = pcall(drv.connect, drv)
>   print(m)
> end
> EOF
[vagrant@bkppgsql ~]$ sysbench --events=1 --db-driver=mysql --mysql-host=non-existing /tmp/test.lua run
sysbench 1.0.14 (using bundled LuaJIT 2.1.0-beta2)

Running the test with following options:
Number of threads: 1
Initializing random number generator from current time

Initializing worker threads...

Threads started!

FATAL: unable to connect to MySQL server on host 'non-existing', port 3306, aborting...
FATAL: error 2005: Unknown MySQL server host 'non-existing' (0)
connection creation failed
SQL statistics:
    queries performed:
        read:                            0
        write:                           0
        other:                           0
        total:                           0
    transactions:                        1      (159.60 per sec.)
    queries:                             0      (0.00 per sec.)
    ignored errors:                      0      (0.00 per sec.)
    reconnects:                          0      (0.00 per sec.)

General statistics:
    total time:                          0.0043s
    total number of events:              1

Latency (ms):
         min:                                    4.11
         avg:                                    4.11
         max:                                    4.11
         95th percentile:                        4.10
         sum:                                    4.11

Threads fairness:
    events (avg/stddev):           1.0000/0.00
    execution time (avg/stddev):   0.0041/0.00

[vagrant@bkppgsql ~]$
rameshvs02 commented 6 years ago

This issue is reproducible with 1.0.13 build too.

akopytov commented 6 years ago

Wait, the above test shows that the issue is NOT reproducible, i.e. connection to a host named 'non-existing' fails as it should. Whether in your original report it succeeded.

rameshvs02 commented 6 years ago

okay, but when we run ./test_run.sh from testsuite t/api_sql_mysql.t will fail

~/sysbench-1.0.14/tests ~
t/1st.t: passed
t/api_basic.t: passed
t/api_histogram.t: passed
t/api_legacy_basic.t: passed
t/api_legacy_rand.t: passed
t/api_legacy_sql.t: passed
t/api_rand.t: passed
t/api_reports.t: passed
t/api_sql_mysql.t: failed
--- t/api_sql_mysql.t
+++ t/api_sql_mysql.t.err
@@ -67,9 +67,7 @@
   2
   --
   reconnects = 1
-  FATAL: unable to connect to MySQL server on host 'non-existing', port 3306, aborting...
-  FATAL: error 2005: Unknown MySQL server host 'non-existing' (0)
-  connection creation failed
+  <sql_connection>
   --
   FATAL: mysql_drv_query() returned error 1048 (Column 'a' cannot be null) for query 'INSERT INTO t VALUES (NULL)'
   Got an error descriptor:
t/api_sql_pgsql.t: skipped
t/cmd_cleanup.t: passed
t/cmd_help.t: passed
t/cmdline.t: passed
t/cmd_prepare.t: passed
t/cmd_run.t: passed
t/commands.t: passed
t/drivers.t: passed
t/drv_mysql.t: passed
t/drv_pgsql.t: skipped
t/help_drv_mysql.t: passed
t/help_drv_pgsql.t: skipped
t/opt_help.t: passed
t/opt_histogram.t: passed
t/opt_report_checkpoints.t: passed
t/opt_report_interval.t: passed
t/opt_version.t: passed
t/script_bulk_insert_mysql.t: passed
t/script_bulk_insert_pgsql.t: skipped
t/script_oltp_delete_mysql.t: passed
t/script_oltp_delete_pgsql.t: skipped
t/script_oltp_help.t: passed
t/script_oltp_insert_mysql.t: passed
t/script_oltp_insert_pgsql.t: skipped
t/script_oltp_point_select_mysql.t: passed
t/script_oltp_point_select_pgsql.t: skipped
t/script_oltp_read_write_mysql.t: passed
t/script_oltp_read_write_pgsql.t: skipped
t/script_select_random_mysql.t: passed
t/script_select_random_pgsql.t: skipped
t/test_cpu.t: passed
t/test_fileio.t: passed
t/test_memory.t: passed
t/test_mutex.t: passed
t/tests.t: passed
t/test_threads.t: passed
# Ran 45 tests, 9 skipped, 1 failed.
akopytov commented 6 years ago

Two questions:

rameshvs02 commented 6 years ago

Here is there command I use for testsuite run.

pushd $SYSBENCH_SOURCE/tests
export SBTEST_MYSQL_ARGS="--mysql-host=localhost --mysql-user=root --mysql-socket=/tmp/mysql.sock --mysql-db=sbtest"
./test_run.sh
popd

I used globally installed sysbench package for manual testing but the version is same (Installed it from percona testing repo) .

./test_run.sh should use locally build sysbench binary right?

akopytov commented 6 years ago

Bingo, --mysql-socket=/tmp/mysql.sock in SBTEST_MYSQL_ARGS is the reason. When --mysql-socket is specified, sysbench ignores --mysql-host and assumes localhost.

rameshvs02 commented 6 years ago

ack, thanks :)

rameshvs02 commented 6 years ago

Works fine without socket

[vagrant@bkppgsql tests]$ export SBTEST_MYSQL_ARGS="--mysql-host=localhost --mysql-user=root  --mysql-db=sbtest"            [vagrant@bkppgsql tests]$ ./test_run.sh
t/1st.t: passed
t/api_basic.t: passed
t/api_histogram.t: passed
t/api_legacy_basic.t: passed
t/api_legacy_rand.t: passed
t/api_legacy_sql.t: passed
t/api_rand.t: passed
t/api_reports.t: passed
t/api_sql_mysql.t: passed
t/api_sql_pgsql.t: skipped
t/cmd_cleanup.t: passed
t/cmd_help.t: passed
t/cmdline.t: passed
t/cmd_prepare.t: passed
t/cmd_run.t: passed
t/commands.t: passed
t/drivers.t: passed
t/drv_mysql.t: passed
t/drv_pgsql.t: skipped
t/help_drv_mysql.t: passed
t/help_drv_pgsql.t: skipped
t/opt_help.t: passed
t/opt_histogram.t: passed
t/opt_report_checkpoints.t: passed
t/opt_report_interval.t: passed
t/opt_version.t: passed
t/script_bulk_insert_mysql.t: passed
t/script_bulk_insert_pgsql.t: skipped
t/script_oltp_delete_mysql.t: passed
t/script_oltp_delete_pgsql.t: skipped
t/script_oltp_help.t: passed
t/script_oltp_insert_mysql.t: passed
t/script_oltp_insert_pgsql.t: skipped
t/script_oltp_point_select_mysql.t: passed
t/script_oltp_point_select_pgsql.t: skipped
t/script_oltp_read_write_mysql.t: passed
t/script_oltp_read_write_pgsql.t: skipped
t/script_select_random_mysql.t: passed
t/script_select_random_pgsql.t: skipped
t/test_cpu.t: passed
t/test_fileio.t: passed
t/test_memory.t: passed
t/test_mutex.t: passed
t/tests.t: passed
t/test_threads.t: passed
# Ran 45 tests, 9 skipped, 0 failed.
[vagrant@bkppgsql tests]$