Bug #101439 Forced to specify --host when using --socket with util.dumpInstance
Submitted: 3 Nov 2020 13:57 Modified: 2 Oct 2021 20:04
Reporter: Ceri Williams Email Updates:
Status: Closed Impact on me:
None 
Category:Shell General / Core Client Severity:S3 (Non-critical)
Version:8.0.21, 8.0.22 OS:Any
Assigned to: CPU Architecture:Any
Tags: dumpInstance, mysqlsh

[3 Nov 2020 13:57] Ceri Williams
Description:
The user is unnecessarily forced to specify the --host argument for mysqlsh when already using --socket and wishing to execute something like util.dumpInstance()
 

How to repeat:
# Main client OK
=> mysqlsh --socket=/tmp/mysql_sandbox8022.sock --user=root                
MySQL Shell 8.0.21

Copyright (c) 2016, 2020, 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' or '\?' for help; '\quit' to exit.
Creating a session to 'root@/tmp%2Fmysql_sandbox8022.sock'
Fetching schema names for autocompletion... Press ^C to stop.
Your MySQL connection id is 54
Server version: 8.0.22 MySQL Community Server - GPL
No default schema selected; type \use <schema> to set one.
 MySQL  localhost  JS > 
Bye!

=> cat <<EOF > /tmp/test.js
heredoc> util.dumpInstance("/tmp/backup", {threads: 4, showProgress: true});
heredoc> EOF

=> mysqlsh --socket=/tmp/mysql_sandbox8022.sock --user=root -f /tmp/test.js 
Acquiring global read lock
All transactions have been started
Locking instance for backup
Global read lock has been released
Writing global DDL files
Util.dumpInstance: The connection option 'host' has no value. (ArgumentError)
 at /tmp/test.js:1:5
in util.dumpInstance("/tmp/backup", {threads: 4, showProgress: true});
        ^
=> rm -rf /tmp/backup                      
                                                 
=> mysqlsh --socket=/tmp/mysql_sandbox8022.sock --host=localhost --user=root -f /tmp/test.js
Acquiring global read lock
All transactions have been started
Locking instance for backup
Global read lock has been released
Writing global DDL files
Writing users DDL
Running data dump using 4 threads.
Writing DDL for schema `test`
NOTE: Progress information uses estimated values and may not be accurate.
?% (0 rows / ?), 0.00 rows/s, 0.00 B/s uncompressed, 0.00 B/s compressed
Duration: 00:00:00s                                                     
Schemas dumped: 1                                                       
Tables dumped: 0                                                        
Uncompressed data size: 0 bytes                                         
Compressed data size: 0 bytes                                           
Compression ratio: 0.0                                                  
Rows written: 0                                                         
Bytes written: 0 bytes                                                  
Average uncompressed throughput: 0.00 B/s                               
Average compressed throughput: 0.00 B/s

Suggested fix:
The socket alone should be sufficient, do not force unnecessary options to be passed by the user.
[4 Nov 2020 5:14] MySQL Verification Team
Hello Ceri Williams!

Thank you for the report!

Thanks,
Umesh
[2 Oct 2021 20:04] Margaret Fisher
Posted by developer:
 
Changelog entry added for MySQL Shell 8.0.27:

MySQL Shell's instance dump utility util.dumpInstance(), schema dump utility util.dumpSchemas(), and table dump utility util.dumpTables() failed while the user was connected to the server using a socket connection, unless the --host option was also specified.  The utilities include a description of the host in a comment in the dump DDL files, and incorrectly assumed this would be present in the connection options data. The host is now set to localhost for the comment if the --host option is not specified.