-Workaround the known place where 2.3 can leak memory, put notes in on how
to produce the memleak for future fix instead of workaround git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@4112 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
		| @@ -11,6 +11,25 @@ our @EXPORT_OK = qw(extnoderange abbreviate_noderange); | ||||
|  | ||||
| my $missingnodes=[]; | ||||
| my $nodelist; #=xCAT::Table->new('nodelist',-create =>1); | ||||
| my $grptab; | ||||
| #TODO: MEMLEAK note | ||||
| # I've moved grptab up here to avoid calling 'new' on it on every noderange | ||||
| # Something is wrong in the Table object such that it leaks | ||||
| # a few kilobytes of memory, even if nodelist member is not created | ||||
| # To reproduce the mem leak, move 'my $grptab' to the place where it is used | ||||
| # then call 'getAllNodesAttribs' a few thousand times on some table | ||||
| # No one noticed before 2.3 because the lifetime of processes doing noderange  | ||||
| # expansion was short (seconds) | ||||
| # In 2.3, the problem has been 'solved' for most contexts in that the DB worker | ||||
| # reuses Table objects rather than ever destroying them | ||||
| # The exception is when the DB worker process itself wants to expand | ||||
| # a noderange, which only ever happens from getAllNodesAttribs | ||||
| # in this case, we change NodeRange to reuse the same Table object | ||||
| # even if not relying upon DB worker to figure it out for noderange | ||||
| # This may be a good idea anyway, regardless of memory leak | ||||
| # It remains a good way to induce the memleak to correctly fix it  | ||||
| # rather than hiding from the problem | ||||
|  | ||||
| #my $nodeprefix = "node"; | ||||
| my @allnodeset; | ||||
| my $retaincache=0; | ||||
| @@ -153,7 +172,9 @@ sub expandatom { #TODO: implement table selection as an atom (nodetype.os==rhels | ||||
|      } | ||||
|  | ||||
|     # Try to match groups? | ||||
|         my $grptab = xCAT::Table->new('nodegroup'); #TODO: build cache once per noderange and use it instead of repeats | ||||
|         unless ($grptab) { | ||||
|            $grptab = xCAT::Table->new('nodegroup'); #TODO: build cache once per noderange and use it instead of repeats | ||||
|         } | ||||
|         my @grplist; | ||||
|         if ($grptab) {  | ||||
|             @grplist = @{$grptab->getAllEntries()}; | ||||
|   | ||||
| @@ -1,5 +1,13 @@ | ||||
| # IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html | ||||
| #TODO: | ||||
| #MEMLEAK fix | ||||
| # see NodeRange.pm for notes about how to produce a memory leak | ||||
| # xCAT as it stands at this moment shouldn't leak anymore due to what is  | ||||
| # described there, but that only hides from the real problem and the leak will | ||||
| # likely crop up if future architecture changes happen | ||||
| # in summary, a created Table object without benefit of db worker thread | ||||
| # to abstract its existance will consume a few kilobytes of memory | ||||
| # that never gets reused | ||||
| # just enough notes to remind me of the design that I think would allow for | ||||
| #   -cache to persist so long as '_build_cache' calls concurrently stack (for NodeRange interpretation mainly) (done) | ||||
| #   -Allow plugins to define a staleness threshold for getNodesAttribs freshness (complicated enough to postpone...) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user