Uploaded image for project: 'JBoss Enterprise Application Platform'
  1. JBoss Enterprise Application Platform
  2. JBEAP-21830

[GSS](7.3.z) JBJCA-1425 - Datasource clearStatistics operation clears things it shouldn't

    XMLWordPrintable

Details

    • Bug
    • Status: Verified (View Workflow)
    • Major
    • Resolution: Done
    • 7.3.6.GA
    • 7.3.8.CR1, 7.3.8.GA
    • JCA
    • None
    • Hide

      1. increase min/max pool size and enable prefill and statistics.

                  <datasources>
                      <datasource jndi-name="java:jboss/datasources/ExampleDS" pool-name="ExampleDS" enabled="true" use-java-context="true" statistics-enabled="true">
                          <connection-url>jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE</connection-url>
                          <driver>h2</driver>
                          <pool>
                              <min-pool-size>5</min-pool-size>
                              <max-pool-size>5</max-pool-size>
                              <prefill>true</prefill>
                          </pool>
                          <security>
                              <user-name>sa</user-name>
                              <password>sa</password>
                          </security>
                      </datasource>
                      <drivers>
                          <driver name="h2" module="com.h2database.h2">
                              <xa-datasource-class&gt;org.h2.jdbcx.JdbcDataSource</xa-datasource-class&gt;
                          </driver>
                      </drivers>
                  </datasources>
      

      2. deploy reproducer app (h2.zip)
      3. send request to the app, http://localhost:8080/h2/sleep
      4. clear-statistics

      /subsystem=datasources/data-source=ExampleDS/statistics=pool:clear-statistics()
      

      5. check the statistics

      /subsystem=datasources/data-source=ExampleDS/statistics=pool:read-resource(include-runtime=true)
      
      Show
      1. increase min/max pool size and enable prefill and statistics. <datasources> <datasource jndi-name= "java:jboss/datasources/ExampleDS" pool-name= "ExampleDS" enabled= " true " use-java-context= " true " statistics-enabled= " true " > <connection-url>jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE</connection-url> <driver>h2</driver> <pool> <min-pool-size>5</min-pool-size> <max-pool-size>5</max-pool-size> <prefill> true </prefill> </pool> <security> <user-name>sa</user-name> <password>sa</password> </security> </datasource> <drivers> <driver name= "h2" module= "com.h2database.h2" > <xa-datasource- class& gt;org.h2.jdbcx.JdbcDataSource</xa-datasource- class& gt; </driver> </drivers> </datasources> 2. deploy reproducer app (h2.zip) 3. send request to the app, http://localhost:8080/h2/sleep 4. clear-statistics /subsystem=datasources/data-source=ExampleDS/statistics=pool:clear-statistics() 5. check the statistics /subsystem=datasources/data-source=ExampleDS/statistics=pool:read-resource(include-runtime= true )
    • +

    Description

      clear-statistics() set createdCount, destroyedCount and inUseCount to 0. Then following parameters calculated based on these will be wrong values.

      ActiveCount : createdCount.get() - destroyedCount.get()
      AvailableCount : maxPoolSize - inUseCount.get();
      CreatedCount : createdCount.get()
      DestroyedCount : destroyedCount.get()
      IdleCount : getActiveCount() - getInUseCount()
      InUseCount : inUseCount.get()
      

      1. pool has 5 active connections and 1 of in-use.

      [standalone@localhost:9990 /] /subsystem=datasources/data-source=ExampleDS/statistics=pool:read-resource(include-runtime=true)
      {
          "outcome" => "success",
          "result" => {
              "ActiveCount" => 5,
              "AvailableCount" => 4,
              "CreatedCount" => 5,
              "DestroyedCount" => 0,
              "IdleCount" => 4,
              "InUseCount" => 1,
      

      2. clear statistics

      [standalone@localhost:9990 /] /subsystem=datasources/data-source=ExampleDS/statistics=pool:clear-statistics()
      

      3. the statistics become following count.

      [standalone@localhost:9990 /] /subsystem=datasources/data-source=ExampleDS/statistics=pool:read-resource(include-runtime=true)
      {
          "outcome" => "success",
          "result" => {
              "ActiveCount" => 0,    // 5 is correct
              "AvailableCount" => 5, // 4 is correct
              "CreatedCount" => 0,   // 5 is correct
              "DestroyedCount" => 0, // 0 is correct
              "IdleCount" => 0,      // 4 is correct
              "InUseCount" => 0,     // 1 is correct
      

      And if connections are closed by idle-timeout-minutes after clear-statistics(), the destroyedCount can be bigger than createdCount.
      Then clear statistics will happen unexpectedly on every idle-timeout-minutes.

      org.jboss.jca.core.connectionmanager.pool.PoolStatisticsImpl#getActiveCount()
            if (createdCount.get() < destroyedCount.get())
               clear();
      

      Attachments

        Issue Links

          Activity

            People

              chaowan@redhat.com Chao Wang
              rhn-support-hdaicho Hiroki Daicho (Inactive)
              Daniel Cihak Daniel Cihak
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: