Uploaded image for project: 'Red Hat Fuse'
  1. Red Hat Fuse
  2. ENTESB-7611

aries.xa.validateOnMatch does not check stale connections

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • fuse-6.x-GA
    • jboss-fuse-6.3
    • Aries
    • None
    • % %
    • Hide

      Attached is an application with XA Transactions using MySQL.
      You will need to deploy the MySQL JBBC Driver implementation jar to Fuse.

      Getting the below results:

      14:49:14,069 | DEBUG | #4 - timer://foo | SendProcessor                    | 231 - org.apache.camel.camel-core - 2.17.0.redhat-630310 | >>>> Endpoint[sql://INSERT%20INTO%20PLANES%20(number,arrival,departure)%20VALUES%20('1','777','999')?dataSource=%23mysql2XADataSource] Exchange[ID-dhcp193-169-pnq-redhat-com-43007-1513759359612-2-140]
      14:49:14,105 | DEBUG | #4 - timer://foo | TransactionErrorHandler          | 231 - org.apache.camel.camel-core - 2.17.0.redhat-630310 | Transaction commit (0x14aee292) redelivered(unknown) for (MessageId: ID-dhcp193-169-pnq-redhat-com-43007-1513759359612-2-139 on ExchangeId: ID-dhcp193-169-pnq-redhat-com-43007-1513759359612-2-140))
      

      However, when interrupting the database with `systemctl restart mysqld.service`, i can only see the below exception and the transaction being rolled back.

      Caused by: java.sql.SQLException: Failed lazy association with ManagedConnection
      	at org.tranql.connector.jdbc.ConnectionHandle.getManagedConnection(ConnectionHandle.java:81)[334:org.apache.aries.transaction.jdbc:2.1.2]
      	at org.tranql.connector.jdbc.ConnectionHandle.getMetaData(ConnectionHandle.java:456)[334:org.apache.aries.transaction.jdbc:2.1.2]
      

      The suspect and the results that i am seeing here is that either with setting the value for 'aries.xa.validateOnMatch' to 'true' or 'false', i am seeing the same results.

      • There's also customer's test case attached, which probably does not run from our local environment. Attached for reference, test-db2-reconnect_fuse_outside_docker.zip
      Show
      Attached is an application with XA Transactions using MySQL. You will need to deploy the MySQL JBBC Driver implementation jar to Fuse. Getting the below results: 14:49:14,069 | DEBUG | #4 - timer: //foo | SendProcessor | 231 - org.apache.camel.camel-core - 2.17.0.redhat-630310 | >>>> Endpoint[sql://INSERT%20INTO%20PLANES%20(number,arrival,departure)%20VALUES%20( '1' , '777' , '999' )?dataSource=%23mysql2XADataSource] Exchange[ID-dhcp193-169-pnq-redhat-com-43007-1513759359612-2-140] 14:49:14,105 | DEBUG | #4 - timer: //foo | TransactionErrorHandler | 231 - org.apache.camel.camel-core - 2.17.0.redhat-630310 | Transaction commit (0x14aee292) redelivered(unknown) for (MessageId: ID-dhcp193-169-pnq-redhat-com-43007-1513759359612-2-139 on ExchangeId: ID-dhcp193-169-pnq-redhat-com-43007-1513759359612-2-140)) However, when interrupting the database with `systemctl restart mysqld.service`, i can only see the below exception and the transaction being rolled back. Caused by: java.sql.SQLException: Failed lazy association with ManagedConnection at org.tranql.connector.jdbc.ConnectionHandle.getManagedConnection(ConnectionHandle.java:81)[334:org.apache.aries.transaction.jdbc:2.1.2] at org.tranql.connector.jdbc.ConnectionHandle.getMetaData(ConnectionHandle.java:456)[334:org.apache.aries.transaction.jdbc:2.1.2] The suspect and the results that i am seeing here is that either with setting the value for 'aries.xa.validateOnMatch' to 'true' or 'false', i am seeing the same results. There's also customer's test case attached, which probably does not run from our local environment. Attached for reference, test-db2-reconnect_fuse_outside_docker.zip

      Configured `aries.xa.validateOnMatch` as described in [#https://access.redhat.com/documentation/en-us/red_hat_jboss_fuse/6.3/html/transaction_guide/xajdbc-autoenlist.]

      However, this does not have any effects. When requesting a connection, Aries does never call org.apache.aries.transaction.jdbc.internal.ValidatingDelegatingManagedConnectionFactory#isValidConnection.

      Here's what customer's business objective of setting this property:

      • Currently we get stale connections returned from the pool (i. e. Connections with `javax.sql:Connection#isValid() == false`). Business processes using those connections may be aborted (and maybe retried) when getting such connections. We have processes which get multiple times stale connections from the pool and which may give up due to retry limits. We have also periodic jobs running just once a day after the night getting back stale connections and failing because of that. We need to check if there are any stale connections.

      Objective of setting the property:

      GIVEN I have configured `aries.xa.validateOnMatch` (and not `aries.xa.backgroundValidation`) on a Datasource
      WHEN `javax.sql.DataSource#getConnection` is called AND a pooled connection is available
      THEN `javax.sql.Connection#isValid` on that connection will be called (probably via ValidatingDelegatingManagedConnectionFactory#isValidConnection) AND if that function returns `false` (i. e. the connection is invalid) the connection will be removed from the pool and a fresh connection will be allocated and returned.

              ggrzybek Grzegorz Grzybek
              rhn-support-vgohel Viral Gohel (Inactive)
              Tomas Turek Tomas Turek
              Votes:
              1 Vote for this issue
              Watchers:
              9 Start watching this issue

                Created:
                Updated:
                Resolved: