Created by George Ormond Lorch III and last modified
Get this branch:
bzr branch lp:~gl-az/percona-server/BT-23598-bug1167487-5.6
Only George Ormond Lorch III can upload to this branch. If you are George Ormond Lorch III please log in for upload directions.

Branch merges

Related bugs

Related blueprints

Recent revisions

431. By George Ormond Lorch III

Merged from 5.5:

Fix for https://bugs.launchpad.net/percona-server/+bug/1167487 - Enhanced option modifiers do not deallocate memory | Valgrind: getopt_constraint_get_min_value and getopt_constraint_find definitely lost / still reachable

Originally this was just written off as a known, one time leak, which is is, but the failure causes scripted testing to fail and is really just sloppy.

To fix, a new path needed to be created from mysqld main() through my_cleanup and into the my_getopt.c to properly free the options modifiers structures created and saved during option parsing.
A new function was created called handle_options_end() which is called from cleanup() in mysqld.cc. handle_options_end() calls getopt_constraint_deinit() to signal it that it needs to free its internal static data.
getopt_constraint_init() used to contain a static hash table and initialization flag. These were moved out to global scope so that getopt_constraint_deinit() could have access to them.

While testing, a bad memory read/write was discovered in the min and max constraints which caused a crash during freeing of the constraints structs on shutdown. That has been fixed.

While testing, discovered a bug that caused incorrect behavior, reported as https://bugs.launchpad.net/percona-server/+bug/1233294 - certain option modifiers do not have effect
The my_option_constraints hash is hashed on the option name. Option names are normalized ('-' made '_') before inserting into the hash since 'finds' get called from both main where names have not been transformed and from plugins and other places where the names have been transformed.
The issue is that the searches were performed with non-normalized names, so the find function would not find a record for the same option name (innodb_io_capacity vs innodb-io-capacity). It would then create a new record, transform the name and attempt insertion, which would fail silently due to duplicate.
The new record would be returned and used for that particular constraint setting but would be leaked because it did not exist in the hash. The constraing is then not 'recorded' so any attempt to set outside of the constraint would succeed.
Fixed by transforming the name before looking up the constraint in the hash.

Branch metadata

Branch format:
Branch format 7
Repository format:
Bazaar repository format 2a (needs bzr 1.16 or later)
Stacked on:
This branch contains Public information 
Everyone can see this information.