Bug #25175 Too much memory used by MySQL grant system
Submitted: 19 Dec 2006 14:31 Modified: 26 Mar 18:34
Reporter: Sinisa Milivojevic
Status: Closed
Category:Server: Privileges Severity:S3 (Non-critical)
Version:4.0 and higher OS:Any (all)
Assigned to: Kristofer Pettersson Target Version:6.0
Tags: bfsm_2006_12_21, bfsm_2007_05_03
Triage: D3 (Medium)

[19 Dec 2006 14:31] Sinisa Milivojevic
Description:
A privilege system contains the outer hash table, and each entry in this table is an inner
hash table. By default, each inner hash table is allocated to 8 Kb, so that, for example,
each entry in table privileges takes 8 Kb.

How to repeat:
Run: flush privileges.

Suggested fix:
Change hash_init() so that 8 Kb is not allocated during the initialisation.
[15 Mar 0:44] Kristofer Pettersson
The patch can't be applied correctly but a naive test shows that the idea holds for our
code as well (to no major surprise). Using a smaller growth size will according to my test
not affect performance but reduce memory footprint significantly.
[15 Mar 0:44] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/44060

ChangeSet@1.2558, 2008-03-15 00:52:44+01:00, thek@adventure.(none) +3 -0
  Bug#25175 Too much memory used by MySQL grant system
  
  Each time the server reloads privileges containing table grants, the 
  system will allocate too much memory than needed because of badly
  chosen growth prediction in the underlying dynamic arrays.
  
  This patch introduces a new signature to the hash container initializer
  which enables a much more pessimistic approach in favour for more
  efficient memory useage.
  
  This patch was supplied by Google Inc.
[18 Mar 10:37] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/44167

ChangeSet@1.2558, 2008-03-18 10:45:36+01:00, thek@adventure.(none) +3 -0
  Bug#25175 Too much memory used by MySQL grant system
  
  Each time the server reloads privileges containing table grants, the 
  system will allocate too much memory than needed because of badly
  chosen growth prediction in the underlying dynamic arrays.
  
  This patch introduces a new signature to the hash container initializer
  which enables a much more pessimistic approach in favour for more
  efficient memory useage.
  
  This patch was supplied by Google Inc.
[26 Mar 15:13] Bugs System
Pushed into 5.1.24-rc
[26 Mar 18:34] Paul DuBois
Noted in 5.1.24 changelog.

The server uses less memory when loading privileges containing table grants.
(Patch provided by Google.)
[27 Mar 18:50] Bugs System
Pushed into 6.0.5-alpha
[30 Mar 1:23] Jon Stephens
Also noted in the 5.1.23-ndb-6.3.11 and 6.0.5 changelogs.