8 Replies Latest reply on Apr 1, 2005 4:14 AM by Vishak Shanmugam Pillai

    JMS_MESSAGES_PK violated

    isotope1145 Newbie

      Occasionally, after a JBoss server restart we get the following exception when we send a new message:
      java.sql.SQLException: ORA-00001: unique constraint (JMS_MESSAGES_PK) violated

      An investigation of the JBoss source code indicates that the messageIdCounter
      is reset to 0 on JMS server restart. See the following JBoss files in the messaging
      component:
      JMSTopic.java
      JMSDestination.java

      If there are any persistent unprocessed messages in the queue when the server is brought down, there is the possibily of a messageid collision when the server is started. Perhaps the messageIdCounter should be initialized to "select max(messageid) from JMS_MESSAGES"?

        • 1. Re: JMS_MESSAGES_PK violated
          Adrian Brock Master

          Before you start making assumptions, try posting some useful information.

          What messages are in the database that are not getting recovered?
          The recovery process calculates the next message id.

          Also, you will get this problem if you are sharing the db tables with another JBossMQ
          instance.

          • 2. Re: JMS_MESSAGES_PK violated
            Elias Ross Master


            Adrian, there is a real bug in jdbc2/PersistenceManager which you avoided in your jdbc3 PM, with respect to incrementing long values.

            I'm checking a fix for 3.2 branch.

            isotope1145, if you use org.jboss.mq.pm.jdbc3.PersistenceManager (in 3.2.4RC) your problem should go away.

            • 3. Re: JMS_MESSAGES_PK violated
              Elias Ross Master


              For purposes of showing up on a search, here is the trace I get:

              Caused by: org.jboss.mq.SpyJMSException: Could not crate tx: 97107; - nested throwable: (java.sql.SQLException: Violation of unique index: SYS_PK_JMS_TRANSACTIONS in statement [INSERT INTO JMS_TRANSACTIONS (TXID) values(97107)])
              at org.jboss.mq.pm.jdbc2.PersistenceManager.createPersistentTx(PersistenceManager.java:666)
              at org.jboss.mq.pm.TxManager.createTx(TxManager.java:79)
              at org.jboss.mq.server.JMSDestinationManager.transact(JMSDestinationManager.java:424)
              at org.jboss.mq.server.JMSServerInvoker.transact(JMSServerInvoker.java:186)
              at org.jboss.mq.il.jvm.JVMServerIL.transact(JVMServerIL.java:328)
              at org.jboss.mq.Connection.send(Connection.java:928)
              ... 12 more
              Caused by: java.sql.SQLException: Violation of unique index: SYS_PK_JMS_TRANSACTIONS in statement [INSERT INTO JMS_TRANSACTIONS (TXID) values(97107)]
              at org.hsqldb.Trace.getError(Unknown Source)
              at org.hsqldb.jdbcResultSet.(Unknown Source)
              at org.hsqldb.jdbcConnection.executeStandalone(Unknown Source)
              at org.hsqldb.jdbcConnection.execute(Unknown Source)
              at org.hsqldb.jdbcStatement.fetchResult(Unknown Source)
              at org.hsqldb.jdbcStatement.executeUpdate(Unknown Source)
              at org.hsqldb.jdbcPreparedStatement.executeUpdate(Unknown Source)
              at org.jboss.resource.adapter.jdbc.WrappedPreparedStatement.executeUpdate(WrappedPreparedStatement.java:324)
              at org.jboss.mq.pm.jdbc2.PersistenceManager.createPersistentTx(PersistenceManager.java:660)
              ... 17 more

              • 4. Re: JMS_MESSAGES_PK violated
                Adrian Brock Master

                Genman,

                Your fix relates to transactions not messages?
                Can you explain how this would fix a duplicate message id?

                Thanks for the fix by the way.

                Regards,
                Adrian

                • 5. Re: JMS_MESSAGES_PK violated
                  chris effenberger Newbie

                  Hello Adrian, I have a similar problem: want do you mean? thank you for comment.

                  2004-06-21 09:54:04,391 ERROR [com.company.JMSSender](Thread-13 :) 1010
                  7: Fehler beim senden der TIMEOUT-JMS
                  org.jboss.mq.SpyJMSException: Could not store message: 886 msg=0 hard NOT_STORED
                  NON_PERSISTENT queue=QUEUE.PpswwPr priority=4 lateClone=false hashCode=15242197
                  56; - nested throwable: (java.sql.SQLException: Violation of unique index: SYS_P
                  K_JMS_MESSAGES in statement [INSERT INTO JMS_MESSAGES (MESSAGEID, DESTINATION, M
                  ESSAGEBLOB, TXID, TXOP) VALUES(0,'QUEUE.PpswwPr','aced00057372001b6f72672e6a626f
                  73732e6d712e537079546578744d657373616765034578686880ab810c0000787200176f72672e6a
                  626f73732e6d712e5370794d657373616765067bd98e2509da340c00007870776c02000750707377
                  7750720000000100000000000000000000000407001549443a32312d313038373830343337343831
                  333234000000fd46317f1d0109ffffffff000900000107000549443a3231000000010006546c6754
                  79700700025454080000000100075472696767657278',NULL,'T')])
                  at org.jboss.mq.pm.jdbc2.PersistenceManager.saveToStorage(PersistenceMan
                  ager.java:1225)
                  at org.jboss.mq.server.MessageCache.saveToStorage(MessageCache.java:385)
                  at org.jboss.mq.server.MessageReference.makeSoft(MessageReference.java:3
                  11)
                  at org.jboss.mq.server.MessageCache.validateSoftReferenceDepth(MessageCa
                  che.java:332)
                  at org.jboss.mq.server.MessageCache.addInternal(MessageCache.java:142)
                  at org.jboss.mq.server.MessageCache.addInternal(MessageCache.java:142)
                  at org.jboss.mq.server.MessageCache.add(MessageCache.java:112)
                  at org.jboss.mq.server.JMSTopic.addMessage(JMSTopic.java:357)
                  at org.jboss.mq.server.JMSDestinationManager.addMessage(JMSDestinationManager.java:402)
                  at org.jboss.mq.server.JMSDestinationManager.addMessage(JMSDestinationManager.java:378)
                  at org.jboss.mq.server.JMSServerInterceptorSupport.addMessage(JMSServerInterceptorSupport.java:136)
                  at org.jboss.mq.security.ServerSecurityInterceptor.addMessage(ServerSecurityInterceptor.java:153)
                  at org.jboss.mq.server.TracingInterceptor.addMessage(TracingInterceptor.java:279)
                  at org.jboss.mq.il.uil2.ServerSocketManagerHandler.handleMsg(ServerSocketManagerHandler.java(Compiled Code))
                  at org.jboss.mq.il.uil2.SocketManager$ReadTask.handleMsg(SocketManager.java(Compiled Code))
                  at org.jboss.mq.il.uil2.msgs.BaseMsg.run(BaseMsg.java(Compiled Code))
                  at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExecutor.java(Compiled Code))
                  at java.lang.Thread.run(Thread.java(Compiled Code))
                  Caused by: java.sql.SQLException: Violation of unique index: SYS_PK_JMS_MESSAGES in statement [INSERT INTO JMS_MESSAGES (MESSAGEID, DESTINATION, MESSAGEBLOB, TXID, TXOP) VALUES(0,'QUEUE.myQueue','aced00057372001b6f72672e6a626f73732e6d712e537079546578744d657373616765034578686880ab810c0000787200176f72672e6a626f73732e6d712e5370794d657373616765067bd98e2509da340c00007870776c020007507073777750720000000100000000000000000000000407001549443a32312d313038373830343337343831333234000000fd46317f1d0109ffffffff000900000107000549443a3231000000010006546c675479700700025454080000000100075472696767657278',NULL,'T')]
                  at org.hsqldb.Trace.getError(Unknown Source)
                  at org.hsqldb.jdbcResultSet.(Unknown Source)
                  at org.hsqldb.jdbcConnection.executeStandalone(Unknown Source)
                  at org.hsqldb.jdbcConnection.execute(Unknown Source)
                  at org.hsqldb.jdbcStatement.fetchResult(Unknown Source)
                  at org.hsqldb.jdbcStatement.executeUpdate(Unknown Source)
                  at org.hsqldb.jdbcPreparedStatement.executeUpdate(Unknown Source)
                  at org.jboss.resource.adapter.jdbc.WrappedPreparedStatement.executeUpdate(WrappedPreparedStatement.java(Compiled Code))
                  at org.jboss.mq.pm.jdbc2.PersistenceManager.add(PersistenceManager.java:783)
                  at org.jboss.mq.pm.jdbc2.PersistenceManager.saveToStorage(PersistenceManager.java:1211)
                  ... 16 more

                  • 6. Re: JMS_MESSAGES_PK violated
                    Elias Ross Master


                    Which version of JBoss are you running?

                    Try JBoss 3.2.4 release.

                    • 7. Re: JMS_MESSAGES_PK violated
                      chris effenberger Newbie

                      I am working with jboss-3.2.4.
                      Sorry, I thought it is a matter of course.
                      I have read your posting here. So I tried the org.jboss.mq.pm.jdbc3.PersistenceManager. This works fine. Thank you :-) But I thought it was a bug in 3.2.4RC or earlier versions.
                      It seems your bugfix for jboss-3.2.4 doesn´t work in the right way.

                      • 8. Re: JMS_MESSAGES_PK violated
                        Vishak Shanmugam Pillai Newbie

                        I am using Jboss 3.2.3 and am getting the following error message. The JDBC version is 2.0. Will this be solved by using JDBC 3.0. Is this JDBC version change possible without changing Jboss 3.2.3 version.

                        INFO | jvm 1 | 2005/03/25 19:30:54 | processName= acceptance_processCould not store message: 64 msg=2 hard NOT_STORED PERSISTENT queue=TOPIC.LMTopic.ID:3.-2147483648 priority=4 hashCode=27150163; - nested throwable: (java.sql.SQLException: Violation of PRIMARY KEY constraint 'PK__JMS_MESSAGES__6166761E'. Cannot insert duplicate key in object 'JMS_MESSAGES'.)