Commit 72f0efac authored by Jacob Mathew's avatar Jacob Mathew

MDEV-15697: Remote user used by Spider needs SUPER privilege

The remote users need the SUPER privilege because by default Spider sends a
'SET SQL_LOG_OFF' statement to the data nodes.  This is controlled by the
spider_internal_sql_log_off configuration setting on the Spider node, which
can only be set to 0 or 1, with a default value of 1.

I have fixed the problem by changing this configuration setting so that if it
is NOT SET, which is the most likely case, the Spider node DOES NOT SEND the
'SET SQL_LOG_OFF' statement to the data nodes.  However if the
spider_internal_sql_log_off setting IS EXPLICITLY SET to either 0 or 1, then
the Spider node DOES SEND the 'SET SQL_LOG_OFF' statement, requiring a remote
user with the SUPER privilege.  The Spider documentation will be updated to
reflect this change.

Author:
  Jacob Mathew.

Reviewer:
  Kentoku Shiba.
parent 99fa7c6c
...@@ -968,20 +968,25 @@ bool spider_param_use_default_database( ...@@ -968,20 +968,25 @@ bool spider_param_use_default_database(
DBUG_RETURN(THDVAR(thd, use_default_database)); DBUG_RETURN(THDVAR(thd, use_default_database));
} }
static int spider_internal_sql_log_off;
/* /*
FALSE: sql_log_off = 0 -1 :don't know or does not matter; don't send 'SET SQL_LOG_OFF' statement
TRUE: sql_log_off = 1 0 :do send 'SET SQL_LOG_OFF 0' statement to data nodes
*/ 1 :do send 'SET SQL_LOG_OFF 1' statement to data nodes
static MYSQL_THDVAR_BOOL( */
static MYSQL_THDVAR_INT(
internal_sql_log_off, /* name */ internal_sql_log_off, /* name */
PLUGIN_VAR_OPCMDARG, /* opt */ PLUGIN_VAR_RQCMDARG, /* opt */
"Sync sql_log_off", /* comment */ "Manage SQL_LOG_OFF mode statement to the data nodes", /* comment */
NULL, /* check */ NULL, /* check */
NULL, /* update */ NULL, /* update */
TRUE /* def */ -1, /* default */
-1, /* min */
1, /* max */
0 /* blk */
); );
bool spider_param_internal_sql_log_off( int spider_param_internal_sql_log_off(
THD *thd THD *thd
) { ) {
DBUG_ENTER("spider_param_internal_sql_log_off"); DBUG_ENTER("spider_param_internal_sql_log_off");
...@@ -2224,15 +2229,15 @@ char *spider_param_remote_time_zone() ...@@ -2224,15 +2229,15 @@ char *spider_param_remote_time_zone()
static int spider_remote_sql_log_off; static int spider_remote_sql_log_off;
/* /*
-1 :don't set -1 :don't know the value on all data nodes, or does not matter
0 :sql_log_off = 0 0 :sql_log_off = 0 on all data nodes
1 :sql_log_off = 1 1 :sql_log_off = 1 on all data nodes
*/ */
static MYSQL_SYSVAR_INT( static MYSQL_SYSVAR_INT(
remote_sql_log_off, remote_sql_log_off,
spider_remote_sql_log_off, spider_remote_sql_log_off,
PLUGIN_VAR_RQCMDARG, PLUGIN_VAR_RQCMDARG,
"Set sql_log_off mode at connecting for improvement performance of connection if you know", "Set SQL_LOG_OFF mode on connecting for improved performance of connection, if you know",
NULL, NULL,
NULL, NULL,
-1, -1,
......
...@@ -113,7 +113,7 @@ bool spider_param_sync_time_zone( ...@@ -113,7 +113,7 @@ bool spider_param_sync_time_zone(
bool spider_param_use_default_database( bool spider_param_use_default_database(
THD *thd THD *thd
); );
bool spider_param_internal_sql_log_off( int spider_param_internal_sql_log_off(
THD *thd THD *thd
); );
int spider_param_bulk_size( int spider_param_bulk_size(
......
...@@ -1638,16 +1638,21 @@ int spider_check_and_set_sql_log_off( ...@@ -1638,16 +1638,21 @@ int spider_check_and_set_sql_log_off(
SPIDER_CONN *conn, SPIDER_CONN *conn,
int *need_mon int *need_mon
) { ) {
bool internal_sql_log_off; int internal_sql_log_off;
DBUG_ENTER("spider_check_and_set_sql_log_off"); DBUG_ENTER("spider_check_and_set_sql_log_off");
internal_sql_log_off = spider_param_internal_sql_log_off(thd); internal_sql_log_off = spider_param_internal_sql_log_off(thd);
if (internal_sql_log_off != -1)
{
if (internal_sql_log_off) if (internal_sql_log_off)
{ {
spider_conn_queue_sql_log_off(conn, TRUE); spider_conn_queue_sql_log_off(conn, TRUE);
} else { }
else
{
spider_conn_queue_sql_log_off(conn, FALSE); spider_conn_queue_sql_log_off(conn, FALSE);
} }
}
/* /*
if (internal_sql_log_off && conn->sql_log_off != 1) if (internal_sql_log_off && conn->sql_log_off != 1)
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment