[syslog-ng] Memory not freeing up in syslog-ng-3.6.2 during reload
Nitish Saboo
nitish.saboo55 at gmail.com
Wed Jan 8 12:06:10 UTC 2020
Hi Kokan,
>Please first of all correct me if I am wrong. But my assumption is that
you build an application using one of the library in syslog-ng that
provides the patterndb functionality.
Yes, I have built a service with some of the libraries in syslog-ng that
provides the patterndb functionality.I am using the following method to
initialise syslog-ng and patterndb:
PatternDB *patterndb;
int initialize_engine(const gchar* filename, const gchar* _module_path)
{
module_path = _module_path;
app_startup();
msg_init(TRUE);
configuration = cfg_new(0x0302);
plugin_load_module("basicfuncs", configuration, NULL);
plugin_load_module("syslogformat", configuration, NULL);
pattern_db_global_init();
return 0;
}
>In case of syslog-ng the LogDBParser own's a PatternDB. In case of reload
the LogDBParser are destroyed (deinit, free) and the PatternDB is stored in
a kinda map.
When the new LogDBParser is created, it looks up that map if there is a
PatternDB in it and if there is it uses the PatternDB (which holds the
context and messages).
I am reloading the patterndb using the following method, where I am
initially freeing up the existing patterndb instance using
'pattern_db_free' method.Will this free-up the context and messages ?
Is this the correct way to free up the existing patterndb instance ?
int reload_pattern_db(const gchar* filename, key_value_cb cb)
{
if(patterndb!= NULL){
pattern_db_free(patterndb);
}
patterndb = pattern_db_new();
pattern_db_reload_ruleset(patterndb, configuration, filename);
pattern_db_set_emit_func(patterndb, pdbtool_pdb_emit_accumulate, cb);
return 0;
}
Let me clarify my issue to you and hope then you will be able to guide me
correctly.
*ISSUE:*
1) Suppose the patterndb.xml file size is 10MB. When I start the service
the memory usage shows 2% for 10MB file size.
2)With every reload of patterndb(I am increasing the file size of
patterndb.xml for example from 10MB to 11MB), the memory usage keeps on
increasing like 2% to 3%.The increase in memory usage is seen *ONLY* during
reload and not while parsing.This process is repeated and now the file size
is 20 MB and memory usage has shot up to say 8%.
3)But now when I restart the service, the memory usage for the same
patterndb.xml file of size 20MB shows only 4%.
So my concern is why the memory usage is increasing with each reload of
patterndb.xml file but when I restart the service the same size of
patterndb.xml shows less memory usage.
Is this because the message and context are not getting deleted?
Thanks,
Nitish
On Wed, Jan 8, 2020 at 4:28 PM Peter Kokai (pkokai) <
Peter.Kokai at oneidentity.com> wrote:
> Hello,
>
> Please first of all correct me if I am wrong. But my assumption is that
> you build an application using one of the library in syslog-ng that
> provides the patterndb functionality.
>
> In that case reading the syslog-ng administrators guide is not the most
> useful thing to read, well there is no real development documentation
> focusing on patterndb.
>
>
> > 1) Is this because of the message contexts that are persisted on reload,
> the memory is not freeing up at the time of reload of patterndb ?
>
> In case of syslog-ng the LogDBParser own's a PatternDB. In case of reload
> the LogDBParser are destroyed (deinit, free) and the PatternDB is stored in
> a kinda map.
> When the new LogDBParser is created, it looks up that map if there is a
> PatternDB in it and if there is it uses the PatternDB (which holds the
> context and messages).
>
> > 2) Is there a way we can free-up these message contexts without a
> restart ?
>
> Probably there is. A proper free of PatternDB object should suffiece. Try
> that and if not, check out what is leaked.
> Please not that we do not update old releases like your 3.6.2 version.
> Even if you found a valid leak, it won't be fixed by us.
>
> On the other hand if that same issue applies to upstream, that is going to
> be solved sooner or later on upstream so reporting that might be beneficial.
>
>
> --
> Kokan
>
> On Wed, Jan 08, 2020 at 11:11:20AM +0530, Nitish Saboo wrote:
> > CAUTION: This email originated from outside of the organization. Do not
> follow guidance, click links, or open attachments unless you recognize the
> sender and know the content is safe.
> >
> > Hi,
> >
> > I was going through syslog-ng administrators guide and came across the
> following point from the given link:
> >
> > "NOTE:Message contexts are persistent and are not lost when syslog-ng
> OSE is reloaded (SIGHUP), but are lost when syslog-ng OSE is restarted."
> >
> >
> https://nam05.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.syslog-ng.com%2Ftechnical-documents%2Fdoc%2Fsyslog-ng-open-source-edition%2F3.18%2Fadministration-guide%2F72%23TOPIC-1044162&data=02%7C01%7CPeter.Kokai%40oneidentity.com%7C98e50b9febb94766906408d793fd6cc9%7C91c369b51c9e439c989c1867ec606603%7C0%7C0%7C637140588987560053&sdata=TYRUPe088j8cP%2Br8e034XO9J46yY%2FMtlbcEeRisuyno%3D&reserved=0
> >
> > 1) Is this because of the message contexts that are persisted on reload,
> the memory is not freeing up at the time of reload of patterndb ?
> >
> > 2) Is there a way we can free-up these message contexts without a
> restart ?
> >
> > Please correct me if I am wrong or missing something here.
> >
> > Thanks,
> > Nitish
> >
> >
> >
> > On Tue, Jan 7, 2020 at 5:37 PM Nitish Saboo <nitish.saboo55 at gmail.com
> <mailto:nitish.saboo55 at gmail.com>> wrote:
> > Hi Peter,
> >
> > Thanks for your response :)
> > I am seeing the memory usage getting increased ONLY at the time of
> reload of patterndb.
> > All other operation are having constant memory consumption.
> > Hence, my question is specific to reload operation if it is by default
> that patterndb component is not freeing up the memory on reload operation ?
> If it is by default, why is it so ?
> >
> > The init and deinit can be repeated multiple times (init, deinit, init,
> deinit, ...) also usually the repeation of single init is fine (init, init,
> ...).
> > >> With this you meant initialising syslog-ng every-time for every
> reload operation?
> >
> > Thanks,
> > Nitish
> >
> > On Tue, Jan 7, 2020 at 5:05 PM Peter Kokai (pkokai) <
> Peter.Kokai at oneidentity.com<mailto:Peter.Kokai at oneidentity.com>> wrote:
> > Hello,
> >
> > Yes, we like to keep memory for ourselfs ;)[1]
> >
> > This is in fact not syslog-ng reload, and mostly about patterndb
> component. You could verify leak with valgrind or sanitizer. Please if you
> find a leak check it on upstream and report if you have any.
> >
> > Regarding the question that your application does leak or not is hard to
> tell withouth knowing it.
> > Please share your application and we might be able to help you.
> >
> > Just a hint: things in syslog-ng usually like to be called like this:
> >
> > new
> > init
> > deinit
> > free
> >
> > In case of reference counted object also use unref instead of free, and
> ref well to reference stuff.
> >
> > The init and deinit can be repeated multiple times (init, deinit, init,
> deinit, ...) also usually the repeation of single init is fine (init, init,
> ...).
> > (This is of course not a contract by any means.)
> >
> > Have fun.
> >
> > [1] Not really true.
> >
> > --
> > Kokan
> >
> > On Tue, Jan 07, 2020 at 02:35:43PM +0530, Nitish Saboo wrote:
> > > CAUTION: This email originated from outside of the organization. Do
> not follow guidance, click links, or open attachments unless you recognize
> the sender and know the content is safe.
> > >
> > > Hi,
> > >
> > > I am using syslog-ng version 3.6.2:
> > >
> > > syslog-ng --version
> > > syslog-ng 3.6.2
> > > Installer-Version: 3.6.2
> > > Revision:
> > > Compile-Date: May 2 2019 01:20:32
> > > Available-Modules:
> afmongodb,afstomp,afuser,csvparser,afprog,afamqp,cryptofuncs,afsocket,graphite,dbparser,affile,syslogformat,afsocket-notls,system-source,confgen,pseudofile,linux-kmsg-format,basicfuncs
> > > Enable-Debug: off
> > > Enable-GProf: off
> > > Enable-Memtrace: off
> > > Enable-IPv6: on
> > > Enable-Spoof-Source: off
> > > Enable-TCP-Wrapper: off
> > > Enable-Linux-Caps: off
> > >
> > >
> > > I initialised syslog-ng with the following configuration:
> > >
> > > int initialize_engine(const gchar* filename, const gchar* _module_path)
> > > {
> > > module_path = _module_path;
> > > app_startup();
> > > msg_init(TRUE);
> > >
> > > configuration = cfg_new(0x0302);
> > > plugin_load_module("basicfuncs", configuration, NULL);
> > > plugin_load_module("syslogformat", configuration, NULL);
> > >
> > > pattern_db_global_init();
> > > return 0;
> > > }
> > >
> > > int reload_pattern_db(const gchar* filename, key_value_cb cb)
> > > {
> > > if(patterndb!= NULL){
> > > pattern_db_free(patterndb);
> > > }
> > > patterndb = pattern_db_new();
> > > pattern_db_reload_ruleset(patterndb, configuration, filename);
> > > pattern_db_set_emit_func(patterndb, pdbtool_pdb_emit_accumulate, cb);
> > > return 0;
> > > }
> > >
> > > When I reload the syslog-ng, the memory keeps on increasing.Looks like
> syslog-ng is not freeing up the memory.It continues to occupy the memory
> unless the process is restarted.
> > > Just want to understand if it is a sign of memory leak or default
> behavior of syslog-ng to not free-up memory during reload ?
> > >
> > > Thanks,
> > > Nitish
> > >
> >
> > >
> ______________________________________________________________________________
> > > Member info:
> https://nam05.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.balabit.hu%2Fmailman%2Flistinfo%2Fsyslog-ng&data=02%7C01%7CPeter.Kokai%40oneidentity.com%7C98e50b9febb94766906408d793fd6cc9%7C91c369b51c9e439c989c1867ec606603%7C0%7C0%7C637140588987560053&sdata=80UrMalZmN5IOI8fIcul18oeWhcSmGC5Qm3sOATy%2BGo%3D&reserved=0
> > > Documentation:
> https://nam05.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.balabit.com%2Fsupport%2Fdocumentation%2F%3Fproduct%3Dsyslog-ng&data=02%7C01%7CPeter.Kokai%40oneidentity.com%7C98e50b9febb94766906408d793fd6cc9%7C91c369b51c9e439c989c1867ec606603%7C0%7C0%7C637140588987560053&sdata=h2VSO0%2FE6Jya03KEkZHW6EHtZ7VxdWBaO8677wvc73Q%3D&reserved=0
> > > FAQ:
> https://nam05.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.balabit.com%2Fwiki%2Fsyslog-ng-faq&data=02%7C01%7CPeter.Kokai%40oneidentity.com%7C98e50b9febb94766906408d793fd6cc9%7C91c369b51c9e439c989c1867ec606603%7C0%7C0%7C637140588987560053&sdata=RiKxeKjeug6xqe6rbgjM182HcRY8s%2FfEwXOoRB1hK0I%3D&reserved=0
> > >
> >
> ______________________________________________________________________________
> > Member info:
> https://nam05.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.balabit.hu%2Fmailman%2Flistinfo%2Fsyslog-ng&data=02%7C01%7CPeter.Kokai%40oneidentity.com%7C98e50b9febb94766906408d793fd6cc9%7C91c369b51c9e439c989c1867ec606603%7C0%7C0%7C637140588987570048&sdata=Z3g3ZFjOX96kzak8gx87cjSW6on2lLquFk2ZhR7ND%2FE%3D&reserved=0
> > Documentation:
> https://nam05.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.balabit.com%2Fsupport%2Fdocumentation%2F%3Fproduct%3Dsyslog-ng&data=02%7C01%7CPeter.Kokai%40oneidentity.com%7C98e50b9febb94766906408d793fd6cc9%7C91c369b51c9e439c989c1867ec606603%7C0%7C0%7C637140588987570048&sdata=hzVDeYj%2BYUniHgbmzlmbIhucKeweGlR5%2BJc%2Bm70lFvY%3D&reserved=0
> > FAQ:
> https://nam05.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.balabit.com%2Fwiki%2Fsyslog-ng-faq&data=02%7C01%7CPeter.Kokai%40oneidentity.com%7C98e50b9febb94766906408d793fd6cc9%7C91c369b51c9e439c989c1867ec606603%7C0%7C0%7C637140588987570048&sdata=wakZRruKQpuezhA1fU8LPnL5SOpin6bvHB2O5mbf8Ls%3D&reserved=0
> >
>
> >
> ______________________________________________________________________________
> > Member info:
> https://nam05.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.balabit.hu%2Fmailman%2Flistinfo%2Fsyslog-ng&data=02%7C01%7CPeter.Kokai%40oneidentity.com%7C98e50b9febb94766906408d793fd6cc9%7C91c369b51c9e439c989c1867ec606603%7C0%7C0%7C637140588987700002&sdata=iY32Y9gzDT72OLmOWoZBlDrAmu5%2F5AqXF6mX3cEzfTU%3D&reserved=0
> > Documentation:
> https://nam05.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.balabit.com%2Fsupport%2Fdocumentation%2F%3Fproduct%3Dsyslog-ng&data=02%7C01%7CPeter.Kokai%40oneidentity.com%7C98e50b9febb94766906408d793fd6cc9%7C91c369b51c9e439c989c1867ec606603%7C0%7C0%7C637140588987700002&sdata=fVrlGkOS7wkLp%2FuJ8%2Fvvr%2BF223svv64NxyHabEpJS7w%3D&reserved=0
> > FAQ:
> https://nam05.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.balabit.com%2Fwiki%2Fsyslog-ng-faq&data=02%7C01%7CPeter.Kokai%40oneidentity.com%7C98e50b9febb94766906408d793fd6cc9%7C91c369b51c9e439c989c1867ec606603%7C0%7C0%7C637140588987700002&sdata=GGqYNSsa%2Bnw6fy5EROhlJbzkFaCOI7EpUiuCRFFX%2FOY%3D&reserved=0
> >
>
> ______________________________________________________________________________
> Member info: https://lists.balabit.hu/mailman/listinfo/syslog-ng
> Documentation:
> http://www.balabit.com/support/documentation/?product=syslog-ng
> FAQ: http://www.balabit.com/wiki/syslog-ng-faq
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.balabit.hu/pipermail/syslog-ng/attachments/20200108/5cc664c7/attachment-0001.html>
More information about the syslog-ng
mailing list