[MDEV-29827] Misleading error messages about event scheduler when using --skip-grant-tables Created: 2022-10-19  Updated: 2023-07-04  Resolved: 2023-04-27

Status: Closed
Project: MariaDB Server
Component/s: Events
Affects Version/s: 10.3, 10.4, 10.5, 10.6, 10.7, 10.8, 10.9
Fix Version/s: 11.1.1

Type: Bug Priority: Major
Reporter: Daniel Lenski Assignee: Daniel Black
Resolution: Fixed Votes: 0
Labels: None

Attachments: PNG File screenshot-1.png     PNG File screenshot-2.png    
Issue Links:
Problem/Incident
is caused by MDEV-19262 Server error message is unclear if ev... Closed

 Description   

If I start the server with --skip-grant-tables, then CREATE EVENT doesn't work:

The error message is extremely misleading: "Cannot proceed, because event scheduler is disabled", even if (as in this case) I've explicitly set EVENT_SCHEDULER=ON.

$ ./mariadbd --version
./mariadbd  Ver 10.6.10-MariaDB for Linux on x86_64
 
$ ./mariadbd --no-defaults --socket=$PATH --skip-grant-tables --skip-networking --datadir=$DATADIR --event-scheduler=ON &
...
 
$ ./mariadb --no-defaults --socket=$PATH \
   -e 'select @@global.event_scheduler; create event if not exists mysql.test on schedule at current_timestamp + interval 1 minute do select 1;'
+--------------------------+
| @@global.event_scheduler |
+--------------------------+
| ON                       |
+--------------------------+
ERROR 1577 (HY000) at line 1: Cannot proceed, because event scheduler is disabled

This misleading message is a consequence of the fix for MDEV-19262, which changed the previous error message, even though it was more accurate in this case:

From https://github.com/mariadb/server/commit/6c9a6bad4fe90c8bfcfe6dbf46835a39edc95c6f by wlad:

--- a/sql/share/errmsg-utf8.txt
+++ b/sql/share/errmsg-utf8.txt
@@ -5974,2 +5974,2 @@
 ER_EVENTS_DB_ERROR
-        eng "Cannot proceed because system tables used by Event Scheduler were found damaged at server start"
+        eng "Cannot proceed, because event scheduler is disabled"

Ideas:

  1. There should be ≥2 error messages that actually distinguish the distinct cases:
    • Cannot proceed, because event scheduler is disabled (should only be used when EVENT_SCHEDULER=DISABLED, obviously)
    • Cannot proceed, because grant tables are disabled ((this case)
    • Anything else?
  2. Is there any reason the event scheduler can't/shouldn't work with grant tables disabled?


 Comments   
Comment by Daniel Lenski [ 2023-03-10 ]

I am working on a PR for this.

Comment by Daniel Lenski [ 2023-03-10 ]

wenhug pointed out that MySQL docs (https://dev.mysql.com/doc/refman/8.0/en/server-options.html#option_mysqld_skip-grant-tables) reference this behavior (event scheduler disabled as a side effect of --skip-grant-tables).

We should update MariaDB docs to explain it as well.

Comment by Otto Kekäläinen [ 2023-03-18 ]

PR that addresses this was submitted in https://github.com/MariaDB/server/pull/2539 (posting URL here since the Jira git integration is broken and most people reading this Jira will not see the link unless it is posted in a comment).

Comment by Daniel Lenski [ 2023-07-03 ]

Although my PR was approved and merged by danblack, back in April, a recently commit by serg largely reverts it, by removing the distinctive error message for this specific case.

https://github.com/MariaDB/server/commit/eb9ff262e461938a69a9a594e0d3df4037a84fd6#diff-5b5c10b1c90df86d3d3a1a12eafcb34a891dd64897f84a930bcbb25762fe8141

Sergei, can you explain why you decided to revert this change?

Comment by Sergei Golubchik [ 2023-07-03 ]

Did I? There is still an error message when an event scheduler is disabled by --bootstrap or --skip-grants. There is still a message in the error log when a user tries to enable event scheduler with --bootstrap or --skip-grants.

I just consolidated error numbers, using the same error code that the server uses in all similar cases. And I've clarified it, so that the server would directly say what option caused the event scheduler to be disabled, instead of listing every possible option and letting user to figure it out what exactly was used. Otherwise the PR works as merged, reporting both an error to the user and a message to the log.

Comment by Daniel Lenski [ 2023-07-03 ]

And I've clarified it, so that the server would directly say what option caused the event scheduler to be disabled, instead of listing every possible option and letting user to figure it out what exactly was used.

Yeah, that's true. It is an improvement to be explicit about whether it's -bootstrap or -skip-grant-tables which is causing the error (rather than "one or the other")

I just consolidated error numbers, using the same error code that the server uses in all similar cases.

I see. And the consolidated replacement is The MariaDB server is running with the (-skip-grant-tables|-bootstrap) option so it cannot execute this statement.

When I wrote this Jira, I was coming from the point of view that it's very non-obvious which functionality is or isn't disabled by -skip-grant-tables and/or -bootstrap, and that each piece of missing functionality should be individually explained. The documentation of --skip-grant-tables only says that it "gives all users FULL ACCESS to all tables", but doesn't say anything about disabling Event Scheduler or other functionality.

Probably the documentation for -skip-grant-tables and -bootstrap should be updated to specifically mention that Event Scheduler is disabled, so that when end-users get this error message, they're able to find documentation that specifically mentions that this is expected behavior?

Comment by Daniel Lenski [ 2023-07-03 ]

Probably the documentation for --skip-grant-tables and --bootstrap should be updated to specifically mention that Event Scheduler is disabled, so that when end-users get this error message, they're able to find documentation that specifically mentions that this is expected behavior?

Done.

https://mariadb.com/kb/en/mariadbd-options/#-skip-grant-tables

https://mariadb.com/kb/en/event-limitations/

Comment by Sergei Golubchik [ 2023-07-04 ]

Thanks. Another explanation could be that with --skip-grant-tables no tables are read from mysql.* on startup, so all features that need that are disabled. Applies to privileges, UDFs, events, plugins.

I see. And the consolidated replacement is "The MariaDB server is running with the (-skip-grant-tables|-bootstrap) option so it cannot execute this statement"

Yes, this is the error message the server uses when, well, some functionality is disabled by a certain command-line option.
Few examples from existing tests:

INSERT INTO db1.t1 VALUES (1);
ERROR HY000: The MariaDB server is running with the --read-only option so it cannot execute this statement
--
ALTER TABLE t1 REBUILD PARTITION ALL;
ERROR HY000: The MariaDB server is running with the --skip-partition option so it cannot execute this statement
--
SELECT * INTO OUTFILE 'MYSQL_TMP_DIR\\..a..\\..\\..\\B11764517-2.tmp' FROM t1;
ERROR HY000: The MariaDB server is running with the --secure-file-priv option so it cannot execute this statement
--
set password for bar@foo = password("pass word");
ERROR HY000: The MariaDB server is running with the --skip-grant-tables option so it cannot execute this statement

Generated at Thu Feb 08 10:11:35 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.