Bug #84337 Configure mgr with out root user encounter an error
Submitted: 26 Dec 2016 8:50 Modified: 11 Jul 2017 11:52
Reporter: ruiaylin lin Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Group Replication Severity:S2 (Serious)
Version:mysql 5.7.17 OS:Any
Assigned to: CPU Architecture:Any
Tags: group replicaiton, root user

[26 Dec 2016 8:50] ruiaylin lin
Description:
We are using MySQL 5.7.17 to build the group replication testing cluster. for secure reason , i drop the root user .  When i install the group replication plugin , an error occurred in the error log file like this : 

2016-12-26T15:55:23.513294+08:00 0 [ERROR] Plugin group_replication reported: 'Unable to use user root context when contacting the server for internal plugin requests.'
2016-12-26T15:55:23.513343+08:00 0 [ERROR] Plugin group_replication reported: 'Can't use the root account to create the plugin associated user account to access the server.'
2016-12-26T15:55:23.513358+08:00 0 [ERROR] Plugin group_replication reported: 'It was not possible to create the group replication user usedby the plugin for internal operations.'

But if i have the root user ,  I reference the documents , i do not fount any information about this , then i debug the source code of the MySQL with group replication . I fount this : 

in method create_group_replication_user in file  create_group_replication_user.cc .  line number 61 ,  the code is:  
  error= server_interface->set_session_user("root");

root user was parameter of set_session_user. set_session_user 's code is : 

int Sql_service_interface::set_session_user(const char *user)
{
  MYSQL_SECURITY_CONTEXT sc;
  if (thd_get_security_context(srv_session_info_get_thd(m_session), &sc)) {
    /* purecov: begin inspected */
    log_message(MY_ERROR_LEVEL,
                "Error when trying to fetch security context when contacting the"
                " server for internal plugin requests.");
    return 1;
    /* purecov: end */
  }
  if (security_context_lookup(sc, user, "localhost", NULL, NULL))
  {
    /* purecov: begin inspected */
    log_message(MY_ERROR_LEVEL,
                "Unable to use user %s context when contacting the server for"
                " internal plugin requests.", user);
    return 1;
    /* purecov: end */
  }
  return 0;
}

now found the reason of the error . i add root user with all privileges with grant option . The installation of mgr plugin was successful . 

How to repeat:
if you drop root user in your database . and install the mgr plugin using command like this : 

INSTALL PLUGIN group_replication SONAME 'group_replication.so'; 

or configure it in my.cnf : 

plugin_load = "group_replication.so" ; 

Suggested fix:
maybe ,this user can be configured by variable , and give it a default value or something .
[26 Dec 2016 9:06] MySQL Verification Team
Hello ruiaylin lin,

Thank you for the report.
Verified as described.

Thanks,
Umesh
[26 Dec 2016 10:32] Hugo Dubois
Hello,

Duplicate of 82687 ?
[29 Dec 2016 1:09] ruiaylin lin
@ Hugo Dubois , both are the same bug. before  report it,  i do not find 82687
[11 Jul 2017 11:52] Erlend Dahl
[3 Jul 2017 6:40] David Moss

This is fixed in upcoming versions and the following was added to the 5.7.19
and 8.0.2 change logs:
Incompatible Change: Plugins such as Group Replication and X Plugin now use
the mysql.session account added in this version. If you are upgrading from a
previous version which did not include the mysql.session account you must run
mysql_upgrade to ensure the account is created. If mysql_upgrade is not run,
plugins fail to start with the error message There was an error when trying
to access the server with user: mysql.session@localhost. Make sure the user
is present in the server and that mysql_upgrade was ran after a server
update.