Return-Path: X-Original-To: apmail-db-torque-dev-archive@www.apache.org Delivered-To: apmail-db-torque-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 9A1086DB7 for ; Wed, 6 Jul 2011 14:07:42 +0000 (UTC) Received: (qmail 8782 invoked by uid 500); 6 Jul 2011 14:07:42 -0000 Delivered-To: apmail-db-torque-dev-archive@db.apache.org Received: (qmail 8767 invoked by uid 500); 6 Jul 2011 14:07:42 -0000 Mailing-List: contact torque-dev-help@db.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Apache Torque Developers List" Reply-To: "Apache Torque Developers List" Delivered-To: mailing list torque-dev@db.apache.org Received: (qmail 8759 invoked by uid 99); 6 Jul 2011 14:07:42 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 06 Jul 2011 14:07:42 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED,T_RP_MATCHES_RCVD X-Spam-Check-By: apache.org Received: from [140.211.11.116] (HELO hel.zones.apache.org) (140.211.11.116) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 06 Jul 2011 14:07:39 +0000 Received: from hel.zones.apache.org (hel.zones.apache.org [140.211.11.116]) by hel.zones.apache.org (Postfix) with ESMTP id 305EB45FA0 for ; Wed, 6 Jul 2011 14:07:17 +0000 (UTC) Date: Wed, 6 Jul 2011 14:07:17 +0000 (UTC) From: "Thomas Fox (JIRA)" To: torque-dev@db.apache.org Message-ID: <646575954.4072.1309961237195.JavaMail.tomcat@hel.zones.apache.org> Subject: [jira] [Assigned] (TORQUE-115) TorqueInstance.init(Configuration) - wrong implementation MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/TORQUE-115?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Thomas Fox reassigned TORQUE-115: --------------------------------- Assignee: Thomas Fox > TorqueInstance.init(Configuration) - wrong implementation > --------------------------------------------------------- > > Key: TORQUE-115 > URL: https://issues.apache.org/jira/browse/TORQUE-115 > Project: Torque > Issue Type: Bug > Components: Runtime > Affects Versions: 3.2, 3.3-RC1, 3.3-RC2, 3.3-RC3, 3.3 > Environment: Any > Reporter: Adrian Tarau > Assignee: Thomas Fox > Priority: Critical > Fix For: 4.0 > > > I was hunted by this bug for a long time, but I didn't had time to investigate. Since it happens mostly(almost every time) on my workstation and not in production I wasn't worry about it until now, when I have in investigate some huge performance degradation and I cannot do it if the AbstractBaseManager.setRegion doesn't work during development. It is actually also a bug of Scarab(I will post a similar bug in their bug tracking) which it is possible due wrong handling during Torque initialization. > I'm using Scarab (http://scarab.tigris.org/) and they use Turbine & Torque. Everything works nice, except that Torque is initialized twice. > First, it is initialize by Turbine and the stack trace is this one : > main@1, priority=5, in group 'main', status: 'RUNNING' > at org.tigris.scarab.components.TorqueComponent.initialize(TorqueComponent.java:105) > at org.apache.fulcrum.yaafi.framework.container.ServiceComponentImpl.initialize(ServiceComponentImpl.java:280) > at org.apache.fulcrum.yaafi.framework.container.ServiceContainerImpl.incarnate(ServiceContainerImpl.java:472) > at org.apache.fulcrum.yaafi.framework.container.ServiceContainerImpl.incarnate(ServiceContainerImpl.java:522) > at org.apache.fulcrum.yaafi.framework.container.ServiceContainerImpl.initialize(ServiceContainerImpl.java:201) > at org.apache.fulcrum.yaafi.framework.factory.ServiceManagerFactory.create(ServiceManagerFactory.java:141) > at org.apache.turbine.services.yaaficomponent.TurbineYaafiComponentService.init(TurbineYaafiComponentService.java:194) > at org.apache.fulcrum.BaseServiceBroker.initService(BaseServiceBroker.java:398) > at org.apache.fulcrum.BaseServiceBroker.doInitService(BaseServiceBroker.java:477) > at org.apache.fulcrum.BaseServiceBroker.initServices(BaseServiceBroker.java:449) > at org.apache.fulcrum.BaseServiceBroker.init(BaseServiceBroker.java:262) > at org.apache.turbine.Turbine.configure(Turbine.java:707) > at org.apache.turbine.Turbine.init(Turbine.java:193) > at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1,105) > at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:932) > at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3,951) > at org.apache.catalina.core.StandardContext.start(StandardContext.java:4,225) > at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:759) > at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:739) > at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:524) > at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:608) > at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:535) > at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:470) > at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1,122) > at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:310) > at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119) > at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1,021) > at org.apache.catalina.core.StandardHost.start(StandardHost.java:718) > at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1,013) > at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:442) > at org.apache.catalina.core.StandardService.start(StandardService.java:450) > at org.apache.catalina.core.StandardServer.start(StandardServer.java:709) > at org.apache.catalina.startup.Catalina.start(Catalina.java:551) > at sun.reflect.NativeMethodAccessorImpl.invoke0(NativeMethodAccessorImpl.java:-1) > at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) > at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) > at java.lang.reflect.Method.invoke(Method.java:585) > at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:294) > at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:432) > Second time is initialize by a Search Service and the stack trace looks like this : > Thread-2@854, priority=5, in group 'UpdateIndex', status: 'RUNNING' > at org.tigris.scarab.components.TorqueComponent.initialize(TorqueComponent.java:104) > at org.apache.fulcrum.yaafi.framework.container.ServiceComponentImpl.initialize(ServiceComponentImpl.java:280) > at org.apache.fulcrum.yaafi.framework.container.ServiceContainerImpl.incarnate(ServiceContainerImpl.java:472) > at org.apache.fulcrum.yaafi.framework.container.ServiceContainerImpl.incarnate(ServiceContainerImpl.java:522) > at org.apache.fulcrum.yaafi.framework.container.ServiceContainerImpl.initialize(ServiceContainerImpl.java:201) > at org.apache.fulcrum.yaafi.framework.factory.ServiceManagerFactory.create(ServiceManagerFactory.java:141) > at org.apache.turbine.services.yaaficomponent.TurbineYaafiComponentService.init(TurbineYaafiComponentService.java:194) > at org.apache.fulcrum.BaseServiceBroker.getService(BaseServiceBroker.java:572) > at org.tigris.scarab.services.ServiceManager.getService(ServiceManager.java:91) > at org.tigris.scarab.services.ServiceManager.lookup(ServiceManager.java:75) > at org.tigris.scarab.util.word.SearchFactory.getInstance(SearchFactory.java:73) > at org.tigris.scarab.util.word.LuceneSearchIndex$UpdateThread.run(LuceneSearchIndex.java:781) > at java.lang.Thread.run(Thread.java:595) > I'm not sure why Search Service tries to initialize Torque again(it should be initialize by Turbine), anyway this is not related with Torque but this is how I was able to find this bug. > Also they change TorqueComponent, which looks like this : > public class TorqueComponent > extends org.apache.torque.avalon.TorqueComponent > { > > static{ > ScarabUtil.initializeScarab(); > } > > public TorqueComponent() > { > super(); > } > /** > * Creates a new instance. > * > * @param torqueInstance The instance of the Torque core used by > * this component. > */ > protected TorqueComponent(TorqueInstance torqueInstance) > { > super(torqueInstance); > } > /** > * @see org.apache.avalon.framework.configuration.Configurable#configure(org.apache.avalon.framework.configuration.Configuration) > */ > public void configure(Configuration configuration) > throws ConfigurationException > { > // we retrieve the configuration from Turbine runtime @see #initialize() > getLogger().debug("configure(" + configuration + ")"); > } > /** > * @see org.apache.avalon.framework.activity.Initializable#initialize() > */ > public void initialize() > throws Exception > { > getLogger().debug("initialize()"); > //return the configuration object with the torque values only. > Torque.init(Turbine.getConfiguration()); > } > } > You can see they initialize Torque with Turbine configuration(composite configuration, it contains also Torque configuration file) and since TorqueComponent.initialize() is called twice, TorqueInstance.init(Configuration) is called twice. > The current implementation of TorqueInstance.init(Configuration) is wrong. First it changes the configuration and than calls initialize() which should change the current configuration with "conf.subset(Torque.TORQUE_KEY)" . Because Torque was already intialized, TorqueInstance.initialize() returns without changing the configuration with a subset configuration. Due this improper initialization, when Search Services starts Torque gets a composite configuration(Turbine's configuration) instead of a subset of Turbine configuration(Torque's configuration). Every Configuration.getXX() fails (returns default values), cache is not initialized and maybe some other (lazy) things are not correct either. > private synchronized void initialize() throws TorqueException > { > log.debug("initialize()"); > if (isInit) > { > log.debug("Multiple initializations of Torque attempted"); > return; > } > if (conf == null || conf.isEmpty()) > { > throw new TorqueException("Torque cannot be initialized without " > + "a valid configuration. Please check the log files " > + "for further details."); > } > ..... > } > public void init(Configuration conf) > throws TorqueException > { > log.debug("init(" + conf + ")"); > setConfiguration(conf); > initialize(); > } > I will propose a fix for Scarab > if (!Torque.isInit()) { > Torque.init(Turbine.getConfiguration()); > } > but this should be fixed also in Torque to prevent users making mistakes like this one. > Also " log.debug("Multiple initializations of Torque attempted");" was not very inspired because usually you don't activate debug level on Torque, even during development(except you suspect something is really wrong with Torque). It should be logged with error level(better throw an exception) if calling init() is wrong or in the worst case it should skip calls to init() after first call. > I think Torque should throw an exception in initialize() but also should avoid changing the configuration before calling initialize(). > Thanks. -- This message is automatically generated by JIRA. For more information on JIRA, see: http://www.atlassian.com/software/jira --------------------------------------------------------------------- To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org For additional commands, e-mail: torque-dev-help@db.apache.org