mq
  1. mq
  2. MQ-339

In TransactionLogManager class, DEFAULT_TXNLOG_FILE_SIZE value has an incorrect size unit

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 5.0
    • Fix Version/s: 5.0.1 (RI-Bug-Fix)
    • Component/s: broker-core
    • Labels:
      None
    • Environment:

      OpenMQ version 5.0 (Build 14-e) running on Windows 8.

      Description

      When starting up an embedded broker, the initialization of the transaction log file fails if the default file size is being used (i.e. not set explicitly in the configuration.properties file). This causes the broker startup to fail (for version 5.0, version 4.5.2 logged an exception but started anyway).

      This seems to be because of a bug in com.sun.messaging.jmq.jmsserver.persist.file.TransactionLogManager, within the method initTransactionLogOnStartUp().

      When the line...

      SizeString filesize = config.getSizeProperty(TXNLOG_FILE_SIZE_PROP, DEFAULT_TXNLOG_FILE_SIZE);

      ...fails to read a value from the properties file, it uses DEFAULT_TXNLOG_FILE_SIZE. This constant is 10MB, expressed as bytes (10 * 1024 * 1024). The property is interpreted as KB, however, so an attempt is made to set the length of the transaction log file to 10 GB.

      Adding a line like this to the config.properties file proved to be an acceptable workaround:
      imq.persist.file.txnLog.file.size=1024

      A stack trace like is is thrown, presumably because the value being passed to RandomAccessFile.setLength is too big:

      [#|2013-08-13T09:56:25.288+0100|SEVERE|5.0|imq.log.Logger|_ThreadID=1;_ThreadName=main;|ERROR [B3101]: Error retrieving persisted data:
      com.sun.messaging.jmq.jmsserver.util.BrokerException: [B2096]: Unable to load transaction information.
      at com.sun.messaging.jmq.jmsserver.data.TransactionList.<init>(TransactionList.java:235)
      at com.sun.messaging.jmq.jmsserver.core.DestinationList.init(DestinationList.java:2714)
      at com.sun.messaging.jmq.jmsserver.core.CoreLifecycleImpl.initDestinations(CoreLifecycleImpl.java:110)
      at com.sun.messaging.jmq.jmsserver.Broker._start(Broker.java:1233)
      at com.sun.messaging.jmq.jmsserver.Broker.start(Broker.java:447)
      at com.sun.messaging.jmq.jmsserver.BrokerProcess.start(BrokerProcess.java:164)
      at com.sun.messaging.jmq.jmsserver.DirectBrokerProcess.start(DirectBrokerProcess.java:92)
      at com.sun.messaging.jmq.jmsclient.runtime.impl.BrokerInstanceImpl.start(BrokerInstanceImpl.java:207)
      at com.saaconsultants.jms.test.JmsTestEnvironment.startOpenMQ(JmsTestEnvironment.java:195)
      at com.saaconsultants.jms.test.JmsTestEnvironment.start(JmsTestEnvironment.java:101)
      at com.saaconsultants.jms.test.JmsTestHelper.startJmsTestEnvironment(JmsTestHelper.java:95)
      at com.saaconsultants.jms.test.JmsTestHelper.startJmsTestEnvironment(JmsTestHelper.java:35)
      at com.saaconsultants.jms.test.management.ManagementTestsOpenMQ.setUpClass(ManagementTestsOpenMQ.java:31)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:606)
      at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
      at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
      at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
      at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:27)
      at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:30)
      at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
      at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
      at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
      Caused by: com.sun.messaging.jmq.jmsserver.util.BrokerException: Failed to create transaction log file txnlog
      at com.sun.messaging.jmq.jmsserver.persist.file.TransactionLogManager.initTransactionLogOnStartUp(TransactionLogManager.java:567)
      at com.sun.messaging.jmq.jmsserver.persist.file.TransactionLogManager.startup(TransactionLogManager.java:256)
      at com.sun.messaging.jmq.jmsserver.persist.file.FileStore.init(FileStore.java:478)
      at com.sun.messaging.jmq.jmsserver.data.TransactionList.<init>(TransactionList.java:210)
      ... 28 more
      Caused by: java.io.IOException: An attempt was made to move the file pointer before the beginning of the file
      at java.io.RandomAccessFile.setLength(Native Method)
      at com.sun.messaging.jmq.io.txnlog.file.FileTransactionLogWriter.initNewFile(FileTransactionLogWriter.java:349)
      at com.sun.messaging.jmq.io.txnlog.file.FileTransactionLogWriter.init(FileTransactionLogWriter.java:340)
      at com.sun.messaging.jmq.io.txnlog.file.FileTransactionLogWriter.<init>(FileTransactionLogWriter.java:283)
      at com.sun.messaging.jmq.jmsserver.persist.file.TransactionLogManager.initTransactionLogOnStartUp(TransactionLogManager.java:534)
      ... 31 more

        Activity

        Hide
        amyk added a comment - - edited

        The broker property imq.persist.file.txnLog.file.size is set in default.properties. It appears that your application didn't configure for the embedded broker to find the default.properties at startup, e.g. -imqhome or -libhome

        The size unit in the code for DEFAULT_TXNLOG_FILE_SIZE is now fixed in 5.0.1

        Show
        amyk added a comment - - edited The broker property imq.persist.file.txnLog.file.size is set in default.properties. It appears that your application didn't configure for the embedded broker to find the default.properties at startup, e.g. -imqhome or -libhome The size unit in the code for DEFAULT_TXNLOG_FILE_SIZE is now fixed in 5.0.1
        Hide
        Andrew_Scully added a comment -

        Just thought I would provide a little background on the scenario I was working on when I ran into this.

        I was creating a "standalone" broker instance, that could be run anywhere with no external dependencies. This was so that we could easily test our integration with OpenMQ as part of our automated tests (e.g. in a JUNIT test).

        This meant that I couldn't depend on an external OpenMQ installation existing somewhere on the file system. All of the jars came in via Maven, so all I needed to worry about was creating the directory structure (imqhome and varhome) and the configuration files.

        I found that, in 4.5.2, just creating empty .properties files worked fine. With 5.0, I found that I had to set the property mentioned above, but no others.

        After that, the embedded broker worked fine!

        Show
        Andrew_Scully added a comment - Just thought I would provide a little background on the scenario I was working on when I ran into this. I was creating a "standalone" broker instance, that could be run anywhere with no external dependencies. This was so that we could easily test our integration with OpenMQ as part of our automated tests (e.g. in a JUNIT test). This meant that I couldn't depend on an external OpenMQ installation existing somewhere on the file system. All of the jars came in via Maven, so all I needed to worry about was creating the directory structure (imqhome and varhome) and the configuration files. I found that, in 4.5.2, just creating empty .properties files worked fine. With 5.0, I found that I had to set the property mentioned above, but no others. After that, the embedded broker worked fine!
        Hide
        amyk added a comment - - edited

        The broker has a set of fallback properties hard-coded. However these fallback properties do not include all properties in default.properties (for this reason, the broker should be configured to locate the default.properties which is under 'IMQ_HOME/lib', as documented in the Java Developer's Guide http://docs.oracle.com/cd/E18930_01/html/821-2440/gjmtr.html#scrolltoc). imq.persist.file.txnLog.file.size default setting is set in TransactionLogManager and 5.0 has a size unit bug, this bug, for that default value.

        test case
        tonga/jmsclient/direct/direct_bugMQ339

        Show
        amyk added a comment - - edited The broker has a set of fallback properties hard-coded. However these fallback properties do not include all properties in default.properties (for this reason, the broker should be configured to locate the default.properties which is under 'IMQ_HOME/lib', as documented in the Java Developer's Guide http://docs.oracle.com/cd/E18930_01/html/821-2440/gjmtr.html#scrolltoc ). imq.persist.file.txnLog.file.size default setting is set in TransactionLogManager and 5.0 has a size unit bug, this bug, for that default value. test case tonga/jmsclient/direct/direct_bugMQ339

          People

          • Assignee:
            amyk
            Reporter:
            Andrew_Scully
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: