Bug #81060 mysqlsh will hang if you give a folder to \source command
Submitted: 13 Apr 2016 8:15 Modified: 30 Jun 2017 1:48
Reporter: Shahriyar Rzayev Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Document Store: MySQL Shell Severity:S2 (Serious)
Version:5.7.12 OS:Any
Assigned to: CPU Architecture:Any

[13 Apr 2016 8:15] Shahriyar Rzayev
Description:
mysqlsh -u root --py world_x -pBaku12345#

mysql-py>\source world_x-db
^C^C
^Cmysql-py>^C
^Cmysql-py>^C
^Cmysql-py>^C
^Cmysql-py>^C
^Cmysql-py>^C
^Cmysql-py>^C
^Cmysql-py>^C

^Cmysql-py>^C
^Cmysql-py>^C
^Cmysql-py>^C
^Cmysql-py>^C

It will rise CPU:

1698 root      20   0  152000   8092   5108 R 100,0  0,2   2:41.08 mysqlsh

From processlist:

mysql> show processlist;
+----+------+-----------------+---------+---------+------+-------------+------------------+
| Id | User | Host            | db      | Command | Time | State       | Info             |
+----+------+-----------------+---------+---------+------+-------------+------------------+
|  5 | root | localhost:38548 | world_x | Sleep   |  224 | cleaning up | PLUGIN           |
|  6 | root | localhost       | NULL    | Query   |    0 | starting    | show processlist |
+----+------+-----------------+---------+---------+------+-------------+------------------+
2 rows in set (0,00 sec)
 

How to repeat:
See description

Suggested fix:
No idea.
[13 Apr 2016 11:27] MySQL Verification Team
Hello Shahriyar,

Thank you for the report!

Thanks,
Umesh
[20 Feb 2017 16:03] Omar Mendez Andrade
Posted by developer:
 
Seems like mysqlsh not longer hangs, however it crashes with a couple of scenarios generated from this one.

1. Only calling source command , it crashes
{noformat}
[gdlommen@localhost ~]$ mysqlsh --log-level=8 --interactive=full
Welcome to MySQL Shell 1.0.8-rc

Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type '\help', '\h' or '\?' for help, type '\quit' or '\q' to exit.

Currently in JavaScript mode. Use \sql to switch to SQL mode and execute queries.
mysql-js> \source
Usage: \. <filename> | \source <filename>
Segmentation fault (core dumped)
{noformat}

2. Executing the instruction as commented in this bug makes mysqlsh exit (seems like a crash)
{noformat}
[gdlommen@localhost ~]$ mysqlsh -uroot -P33060 --py --schema=world_x 
Creating a Session to 'root@localhost:33060/world_x'
Enter password: 
Node Session successfully established. Default schema `world_x` accessible through db.
Welcome to MySQL Shell 1.0.8-rc

Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type '\help', '\h' or '\?' for help, type '\quit' or '\q' to exit.

Currently in Python mode. Use \sql to switch to SQL mode and execute queries.
mysql-py> \source world_x-db
/usr/bin/python: can't find '__main__' module in 'world_x-db'
{noformat}

It would be good to tell the user a better error info and avoid the mysqlsh exit/crash

Previous to those two commands scenarios i executed the following:

[gdlommen@localhost ~]$ unzip world_x-db.zip
Archive:  world_x-db.zip
   creating: world_x-db/
  inflating: world_x-db/README.txt   
  inflating: world_x-db/world_x.sql  

[gdlommen@localhost ~]$ mysqlsh -uroot -P5717 --sql --recreate-schema --schema=world_x < /home/gdlommen/world_x-db/world_x.sql 
Enter password: 
Recreating schema world_x...

Records: 4079  Duplicates: 0  Warnings: 0

Records: 239  Duplicates: 0  Warnings: 0

Records: 239  Duplicates: 0  Warnings: 0

Records: 984  Duplicates: 0  Warnings: 0
[30 Jun 2017 1:48] Paul DuBois
Posted by developer:
 
Fixed in 1.0.10.

mysqlsh hung if the \source command was given a directory (rather
than file) argument.