Re: POE, log4perl and sqlite
Antti Linno <[email protected]> Fri, 19 Oct 2012 15:59:14 +0300
| Newsgroups | gmane.comp.lang.perl.poe |
|---|---|
| Message-ID | <CA+9KM+LymFTTZNgosLQFET6xEqLdK4G3i98MDT2s6Y5U887f6g@mail.gmail.com> |
Ok, thanks for suggestion. No select is taking place, unless I do it manually and via sqlite client. The crash occurred in the middle of the night, so my interference can be ruled out :D Maybe I should move to a file based logging as this seems more robust. Thank you all for your time. On Fri, Oct 19, 2012 at 3:46 PM, Rocco Caputo <[email protected]> wrote: > Every module seems to be re-initializing your logger. I don't know if it= 's harmful in your situation, but it's not recommended. Wherever you call = Log::Log4perl::init($log_conf) try Log::Log4perl->init_once($log_conf) inst= ead. See: http://search.cpan.org/~mschilli/Log-Log4perl-1.38/lib/Log/Log4p= erl.pm#Initialize_once_and_only_once > > Offhand I don't see anything else that would lock your log database. May= be another program is locking it in SELECT? If that's true, the queries ar= e taking too long for the bot to wait. Maybe you could optimize the table = indexes so the queries complete in time. > > -- > Rocco Caputo <[email protected]> > > On Oct 19, 2012, at 07:04, Antti Linno wrote: > >> Thank you for your kind interest. >> >> The pastebins: >> >> log4perl.conf http://pastebin.com/nY4twgjS >> main file http://pastebin.com/ruYsu2qt >> application logic http://pastebin.com/hMyyBJ0U >> database interaction http://pastebin.com/Cq7d4geK >> >> As you can see, all the perl files are logging, main and application >> import database functions. I have snipped the application and database >> somewhat, but you could see the main structure and how I am doing the >> logging. >> >> Greetings. >> >> On Thu, Oct 18, 2012 at 4:19 PM, Rocco Caputo <[email protected]> wrote: >>> On Oct 18, 2012, at 07:58, Antti Linno wrote: >>> >>>> First of all, I have to apologise. Still no pastebin. >>> >>> We have to apologize, too. You're asking questions about code we canno= t see. This impairs our ability to provide satisfying answers. >>> >>>> But a general tree would be something like that. >>>> >>>> Main POE module, imported submodule1, imported submodule2. All 3 >>>> modules open the same logger conf and use the same sqlite file to >>>> append the log. Theoretically the log file could be locked, if all 3 >>>> or even 2 modules try to write at the same time. >>> >>> No. As others have said, POE doesn't pre-empt. Under ordinary circums= tances, we expect all three modules to call Log::Log4perl sequentially rath= er than concurrently. We don't expect Log::Log4perl suffer from lock conte= ntion. >>> >>> It's very likely that something extraordinary is happening as a result = of code we cannot see. Others have already outlined the most likely reason= s for the symptoms you described. I hope you understand that's the best we= can do without your cooperation. >>> >>>> What would be the nice and tidy thing to do? Initialize logger in main >>>> POE module and pass it to submodules? >>> >>> That's such a good question that Log::Log4perl already answers it: >>> >>> "Why Log::Log4perl->get_logger and not Log::Log4perl->new? We don't wan= t to create a new object every time. Usually in OO-Programming, you create = an object once and use the reference to it to call its methods. However, th= is requires that you pass around the object to all functions and the last t= hing we want is pollute each and every function/method we're using with a h= andle to the Logger: >>> >>> [example omitted] >>> >>> "Instead, if a function/method wants a reference to the logger, it just= calls the Logger's static get_logger($category) method to obtain a referen= ce to the one and only possible logger object of a certain category. That's= called a singleton if you're a Gamma fan." >>> >>> That quote is from http://search.cpan.org/~mschilli/Log-Log4perl-1.38/l= ib/Log/Log4perl.pm#Initialize_via_a_configuration_file >>> >>> -- >>> Rocco Caputo <[email protected]> >