• Vladislav Vaintroub's avatar
    MDEV-20699 mysqldump of routines causes MariaDB to get killed by oom-killer · 1f099418
    Vladislav Vaintroub authored
    The reason for this behavior is that SP get cached, per connection.
    The stored_program_cache is size of this cache, which amounts to 256
    routines by default. A compiled stored procedure can easily be several
    megabytes in size. Thus calling SHOW CREATE PROCEDURE for all stored
    procedures, like mysqldump does, can require significant amount of memory.
    
    Fixed by bypassing the cache for "SHOW CREATE". This should normally be
    fine also perfomance-wise, as cache is meant to be used for repeated
    execution, not repeated SHOW CREATEs.
    
    Added a test to verify that CREATE PROCEDURE + SHOW CREATE PROCEURE do not
    cache, i.e amount of allocated memory does not change.
    
    Note, there is a change in existing behavior in an edge case :
    If "SHOW CREATE PROCEDURE p1" called from p1, after p1 was altered, now
    this will now return altered code. Previour behavior - relied on caching
    and would return old code. The previous behavior might was not necessarily
    correct.
    1f099418
sp.test 219 KB