9 Replies Latest reply on Sep 26, 2003 8:44 AM by mpalicka

    ExceptionSorter usage

    sheetszc

      After reading some of the messages in this forum, I have been trying to track down exactly how an ExceptionSorter is used. It appears that it is called once an SQLException has occured when a connection is actually used by the application. Can anyone confirm this?

      Is there anyway to configure the connection pool manager to "test" the connection before it is "handed off" to the calling code?

      I am still searching for a way to provide transparent failover / high availability and without some mechnism within the connection pool itself, I am not seeing a way to provide this level of failover within JBoss.

      Any insight into this area would be greatly appreciated. Thanks.

        • 1. Re: ExceptionSorter usage
          mpalicka

          As far as I understand the functionality of ExceptionSorter, it is used to determine, whether the exception is fatal or not (fatal means: the connection is broken and unusable). When a fatal exception occurs, then the connection is removed from the pool.
          The problem is, that broken connections are destroyed one by one. If your pool contains 1000 connections, you need 1000 requests (that throw the fatal exception) to clean and re-establish the pool. It would be nice to be able to re-initialize all connections to the same data source when a single connection breaks down.

          • 2. Re: ExceptionSorter usage
            mpalicka

            It seems that I was wrong. I made some more tests and the server re-established the pool without removing all connections one by one.

            • 3. Re: ExceptionSorter usage
              jfair

              Is the ExceptionSorter supported in JBoss3.0.4? If not, how can I get the connection pool to refresh its pool of connections if the connections are stale/invalid?

              • 4. Re: ExceptionSorter usage
                rixc

                Hi All,

                I have implemented an ExceptionSorter for my AS400 connection.

                The reconnect works, eventually, but only after it fails one time to recreate the connection.

                In other words, when the connection is lost, I get an error when using the connection then after that it manages to reconnect again. Is this the normal behaviour?

                Here is the configuration of my datasource

                <local-tx-datasource>
                <jndi-name>ODCDTA</jndi-name>
                <connection-url>jdbc:as400:<<IP-ADDRESS>>/ODCDTA;Libraries=ODCDTA</connection-url>
                <driver-class>com.ibm.as400.access.AS400JDBCDriver</driver-class>
                <idle-timeout-minutes>5</idle-timeout-minutes>
                <application-managed-security/>
                <exception-sorter-class-name>com.odc.server.jboss.jdbc.AS400ExceptionSorter</exception-sorter-class-name>
                </local-tx-datasource>


                and here is the content of the isExceptionFatal method
                public boolean isExceptionFatal(SQLException e)
                {
                boolean ret = false;

                if(e != null && e.getSQLState() != null)
                ret = (e.getSQLState().equals("08003") || e.getSQLState().equals("08S01") || e.getSQLState().equals("40003"));

                if(ret)
                getLogger().debug("Connection closed by AS400. SQLState=(" + e.getSQLState() + "). Forcing reconnect. Error recieved:\n" + e.getMessage());

                return ret;
                }


                Ricardo

                • 5. Re: ExceptionSorter usage
                  sheetszc

                  So if I understand the posts in this thread correctly, the ExceptionSorter is only used to determine if a connection related exception should be classified as fatal or not and if it is then destroy the connection and create a new one. But this does not occur until the connection has been used by the "requester". The user will therefore see that an exception occured, which is not ideal.

                  This is fine but it still does not meet the requirements for a highly available system. In a highly available system, the user should not have any clue that an invalid connection was used in the first place, The connection pool should be responsible for "testing" the connection by doing an initial "ping" of the server and only if this ping was successful should the connection be handed off to the connection "requester". Of course, there would be a performance penalty involved for taking the extra server hit for the initial ping but this would be a tradeoff for providing transparent database failover. It doesn't seem like this would be hard to implement and is critical for any mission critical enterprise level application.

                  Thoughts?

                  • 6. Re: ExceptionSorter usage
                    mpalicka

                    AFAIK the ExceptionSorter is not supported in JBoss 3.0.4.
                    I made some tests and it seems that 3.0.4 is able to refresh connections anyway. I stopped my database while the application server was running. JBoss started throwing exceptions (complaining that the database/network IO error occured). Then I re-started the database and after some time (a few minutes) my application connected to the database again. I tested this with JBoss 3.0.4 and JBoss 3.2.1, my database is MySQL.
                    It appears that you can make do without an ExceptionSorter. I must admit now that I don't completely understand what is the intended purpose of exception sorters. :-))

                    • 7. Re: ExceptionSorter usage
                      mpalicka

                      In the data-source configuration file, it is possible to define an SQL statement, that will test the validity of a connection before it is returned from the pool. Use the "check-valid-connection-sql" tag.

                      • 8. Re: ExceptionSorter usage
                        jfair


                        I am using Oracle 8.1.7 and jboss 3.0.4. I also ran some tests but the connections are not refreshed. I disconnected my LAN toggle from the network adapter card and tried connecting to the database through my application - an exception was thrown. After reconnecting the toggle to the network card and any subsequent attempts to reconnect to the database, cause an exception to be thrown (socket error). The connections returned from the pool are stale or invalid. In my opinion, it should be the job of the connection pool to check whether the connection it is returning is valid before returning a connection. The ExceptionSorter is supposed to handle these type of errors (i.e. socket error) and refresh the pool of connections - it's a shame it's not available in 3.0.4 because that's exactly what I need.

                        jfair

                        • 9. Re: ExceptionSorter usage
                          mpalicka

                          I forgot to mention, that my database and application server run on the same machine (Windows XP). In this case it might be easier to re-establish lost connections.

                          The <check-valid-connection-sql> tag I mentioned in my previous post is also not available in JBoss 3.0.4.