[MDEV-23893] If we set expire_logs_days=p in my.cnf, 10.3.24 started successfully without giving error. Created: 2020-10-06  Updated: 2021-10-06

Status: Confirmed
Project: MariaDB Server
Component/s: Replication
Affects Version/s: 10.3.24, 10.3, 10.4, 10.5
Fix Version/s: 10.6

Type: Bug Priority: Minor
Reporter: Nilnandan Joshi Assignee: Rucha Deodhar
Resolution: Unresolved Votes: 0
Labels: beginner-friendly


 Description   

Hi Team,

In MariaDB 10.3.23, if we set expire_logs_days=p in my.cnf, server will not start and gives error like "unknown variable" because as per the doc, datatype of this variable is numeric.
https://mariadb.com/kb/en/replication-and-binary-log-system-variables/#expire_logs_days

2020-10-06 10:11:08 0 [ERROR] /home/nilnandan/Downloads/10.3.23/bin/mysqld: unknown variable 'expire_log_days=p'

But in MariaDB 10.3.24, if we do the same, it didn't give error and server is started successfully without any error.



 Comments   
Comment by Alice Sherepa [ 2020-10-06 ]

Indeed, 10.3-10.5 server starts with --expire_logs_days=p, but it is not changed in 10.3.24, but in 10.3.3.
KB says "Variables that take a numeric size can either be specified in full, or with a suffix for easier readability. [ https://mariadb.com/kb/en/server-system-variables/#setting-server-system-variables ] = p for petabytes
So server truncates --expire_logs_days=PMbjbjabfvj to 0 and starts,
but --expire_logs_days=HJHkbaxcp - returns "Unknown suffix 'H' used for variable 'expire_logs_days' (value 'HJHkbaxcp')"
-----------------
On 10.3.23 there was a typo 'expire_log_days' instead of 'expire_logs_days' -so server did not start, not because of 'p'

Comment by Nilnandan Joshi [ 2020-10-07 ]

Isn't there mentioned about suffix and not prefix? Here we are giving P as prefix and still it didn't give any warning or error. Even if we give any other value like "HJH" something, server didn't start and no error mentioned in mariadb error log. I've tested it with 10.3.24. You are right that the same behaviour is in 10.3.24. (it was typo) but the question is if we put any other value like expire_logs_days=abc or expire_logs_days=def why it didn't give any warning or error? In this server didn't start but nothing in mariadb error log.

Comment by Alice Sherepa [ 2020-10-07 ]

I get

 [ERROR] /10.3.24/bin/mysqld: Error while setting value 'jkhjk' to 'expire_logs_days'

immediately after attempt to start (not in a log)

Comment by Sergei Golubchik [ 2020-10-07 ]

It is documented that =<number><unit> works for command line options. That =<unit><garbage> works — this could be really unexpected. Better to fix it.

Still there's a question, =5garbage — should this work or not? This is =<number><unit><garbage>, not as clear-cut as two previous cases.

Comment by Nilnandan Joshi [ 2020-10-08 ]

With 5garbage value, server is getting start and set value to 99.

nilnandan@yoga730:~/sandboxes/msb_10_3_24$ cat my.sandbox.cnf | grep expire
expire_logs_days=5garbage
nilnandan@yoga730:~/sandboxes/msb_10_3_24$ ./start
. sandbox server started
nilnandan@yoga730:~/sandboxes/msb_10_3_24$ mysql -umsandbox --socket=/tmp/mysql_sandbox10324.sock -p
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 8
Server version: 10.3.24-8-MariaDB-enterprise MariaDB Enterprise Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> show global variables like 'expire%';
+------------------+-------+
| Variable_name    | Value |
+------------------+-------+
| expire_logs_days | 99    |
+------------------+-------+
1 row in set (0.010 sec)
MariaDB [(none)]> 

Comment by Sergei Golubchik [ 2020-11-04 ]

I know that it works. The value is 5G, five gigabytes. The question was should it work? Do we want it to?
=garbage works and we definitely don't want it to. But what about =5garbage?

It's probably better if it wouldn't

Comment by Sergei Golubchik [ 2021-07-29 ]
  • it's a minor bug, let's fix it in 10.6 only?
  • the fix should be in both eval_num_suffix_ll() and eval_num_suffix_ull()
    like

    @@ -1019,7 +1019,7 @@ static longlong eval_num_suffix_ll(char *argument,
       *error= 0;
       errno= 0;
       num= strtoll(argument, &endchar, 10);
    -  if (errno == ERANGE)
    +  if (errno == ERANGE || argument == endchar)
       {
         my_getopt_error_reporter(ERROR_LEVEL,
                                  "Incorrect integer value: '%s'", argument);
    

  • the rest can be done inside eval_num_suffix(), to have the check only in one place. like

    @@ -974,6 +974,11 @@
     
     static inline ulonglong eval_num_suffix(char *suffix, int *error)
     {
    +  if (suffix[0] && suffix[1])
    +  {
    +    *error= 1;
    +    return 0ULL;
    +  }
       switch (*suffix) {
       case '\0':
         return 1ULL;
    

Generated at Thu Feb 08 09:25:51 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.