Bug #82726 SET PERSIST writes default values to mysqld-auto.conf rather than removing them
Submitted: 25 Aug 2016 16:02 Modified: 6 Sep 2016 18:26
Reporter: Paul DuBois Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Options Severity:S3 (Non-critical)
Version:8.0.0 OS:Any
Assigned to: CPU Architecture:Any

[25 Aug 2016 16:02] Paul DuBois
Description:
If a variable has not been persisted to mysqld-auto.conf with SET PERSIST, using either
SET PERSIST var_name = DEFAULT;
or
SET PERSIST var_name = literal_var_name_default_value;
results in the following behavior:

The first time the statement is executed, a setting for var_name is written to mysqld-auto.cnf (with the variable set to its default value).
The second time the statement is executed, no setting for var_name is written to mysqld-auto.cnf.

Using SET PERSIST to set a variable either to DEFAULT or to its literal value is supposed to remove it from mysqld-auto.cnf.

How to repeat:
Suppose that max_connections is not listed in mysqld-auto.cnf.

Execute this statement:
SET PERSIST max_connections = DEFAULT;

Examine mysqld-auto.cnf:
{ "mysql_server": {"max_connections": "151" } }

That's incorrect, there should be no max_connections setting.

Execute the statement again:
SET PERSIST max_connections = DEFAULT;

Examine mysqld-auto.cnf again:
{ "mysql_server": { } }

That's correct: No setting for max_connections.

Suggested fix:
If SET PERSIST is used to set a variable either to DEFAULT or to its literal value, rewrite mysqld-auto.cnf but without any setting for the variable.
[6 Sep 2016 18:26] Paul DuBois
Posted by developer:
 
Noted in 8.0.1 changelog.

Using SET PERSIST (or @@persist.) to set a global variable to DEFAULT
or to the variable literal variable assigns the variable its default
value.

Previously, this also added a setting for the variable to the
mysqld-auto.cnf file if was is not present, and removed it from
mysqld-auto.cnf if it was present. Now, assigning DEFAULT to the 
variable removes it from the mysqld-auto.cnf file, and assigning its
literal default value adds a setting for the variable to
mysqld-auto.cnf file.
[19 Sep 2016 8:40] Erlend Dahl
Bug#82806 MySQL server crashes when trying to persist enforce_gtid_consistency

was marked as a duplicate.
[23 Feb 2017 18:19] Paul DuBois
Posted by developer:
 
Revised changelog entry:

Using SET PERSIST (or @@persist.) to set a global variable to DEFAULT
or to the variable literal default value assigns the variable its
default value.

Previously, assigning DEFAULT or the literal default value also added
a setting for the variable to the mysqld-auto.cnf file if was is not
present, and removed it from mysqld-auto.cnf if it was present. Now
the assignment always adds a setting for the variable to
mysqld-auto.cnf file.