2 Replies Latest reply on Mar 17, 2005 6:32 PM by Paul Casal

    Repeatable reads on read-only methods

    Vitaliy Morarian Newbie

      I'm working in the 'B' commit-option. During stress-test of application we have got a deadlock's. So, I decided to tune application.
      Commit-option couldn't be changed to 'A'.
      I started from setting methods as read-only. After changing I have analyzed a jboss log file and saw repeatable reads (depending on count of executed methods from the entity).

      Step by step:

      Have a command which executes a dynamic query on entity bean (Timeframe).
      Dynamic query must return list of entities. Populated only 3 fields.

      ---------------------------------------
      2005-03-02 10:56:49,328 DEBUG [Smash] | >ListTimeframeCommand.execute
      2005-03-02 10:56:49,343 DEBUG [org.jboss.ejb.plugins.cmp.jdbc.JDBCDynamicQLQuery.TimeframeEJB#ejbSelectGeneric] DYNAMIC-QL: SELECT OBJECT($timeframes) FROM timefram
      es AS $timeframes WHERE ($timeframes.organizationId = ?1)
      2005-03-02 10:56:49,343 DEBUG [org.jboss.ejb.plugins.cmp.jdbc.JDBCDynamicQLQuery.TimeframeEJB#ejbSelectGeneric] Executing SQL: SELECT t0_$timeframes.timeframe_id FR
      OM timeframes t0_$timeframes WHERE ((t0_$timeframes.organization_id = ?))
      2005-03-02 10:56:49,343 DEBUG [org.jboss.mx.loading.UnifiedClassLoader] New jmx UCL with url null
      2005-03-02 10:56:49,343 DEBUG [org.jboss.mx.loading.UnifiedClassLoader] setRepository, r=org.jboss.mx.loading.HeirarchicalLoaderRepository3@157444f, ucl=org.jboss.m
      x.loading.UnifiedClassLoader3@1c90649{ url=null ,addedOrder=0}
      2005-03-02 10:56:49,359 DEBUG [org.jboss.mx.loading.UnifiedClassLoader] New jmx UCL with url null
      2005-03-02 10:56:49,359 DEBUG [org.jboss.mx.loading.UnifiedClassLoader] setRepository, r=org.jboss.mx.loading.HeirarchicalLoaderRepository3@157444f, ucl=org.jboss.m
      x.loading.UnifiedClassLoader3@1320ebf{ url=null ,addedOrder=0}
      2005-03-02 10:56:49,359 DEBUG [org.jboss.mx.loading.UnifiedClassLoader] New jmx UCL with url null
      2005-03-02 10:56:49,359 DEBUG [org.jboss.mx.loading.UnifiedClassLoader] setRepository, r=org.jboss.mx.loading.HeirarchicalLoaderRepository3@157444f, ucl=org.jboss.m
      x.loading.UnifiedClassLoader3@d290f2{ url=null ,addedOrder=0}
      2005-03-02 10:56:49,359 DEBUG [org.jboss.mx.loading.UnifiedClassLoader] New jmx UCL with url null
      2005-03-02 10:56:49,359 DEBUG [org.jboss.mx.loading.UnifiedClassLoader] setRepository, r=org.jboss.mx.loading.HeirarchicalLoaderRepository3@157444f, ucl=org.jboss.m
      x.loading.UnifiedClassLoader3@942210{ url=null ,addedOrder=0}
      2005-03-02 10:56:49,359 DEBUG [org.jboss.ejb.plugins.cmp.jdbc.JDBCLoadEntityCommand.TimeframeEJB] Executing SQL: SELECT timeframe_id, name, organization_id, duratio
      n, start_time, finish_time FROM timeframes WHERE (timeframe_id=?) OR (timeframe_id=?) OR (timeframe_id=?) OR (timeframe_id=?) OR (timeframe_id=?) OR (timeframe_id=?
      ) OR (timeframe_id=?) OR (timeframe_id=?) OR (timeframe_id=?) OR (timeframe_id=?) OR (timeframe_id=?) OR (timeframe_id=?) OR (timeframe_id=?) OR (timeframe_id=?) OR
      (timeframe_id=?) OR (timeframe_id=?) OR (timeframe_id=?) OR (timeframe_id=?) OR (timeframe_id=?) OR (timeframe_id=?)
      2005-03-02 10:56:49,437 DEBUG [Smash] | <ListTimeframeCommand.execute
      ---------------------------------------


      Setting in jboss.xml getter methods as read-only

      <ejb-name>TimeframeEJB</ejb-name>
      <local-jndi-name>ejb/SMASH/LocalTimeframe</local-jndi-name>
      <method-attributes>

      <method-name>get*</method-name>
      <read-only>true</read-only>

      </method-attributes>


      After executing have:
      ---------------------------------------
      2005-03-02 11:08:33,203 DEBUG [Smash] | >ListTimeframeCommand.execute
      2005-03-02 11:08:33,218 DEBUG [org.jboss.ejb.plugins.cmp.jdbc.JDBCDynamicQLQuery.TimeframeEJB#ejbSelectGeneric] DYNAMIC-QL: SELECT OBJECT($timeframes) FROM timefram
      es AS $timeframes WHERE ($timeframes.organizationId = ?1)
      2005-03-02 11:08:33,218 DEBUG [org.jboss.ejb.plugins.cmp.jdbc.JDBCDynamicQLQuery.TimeframeEJB#ejbSelectGeneric] Executing SQL: SELECT t0_$timeframes.timeframe_id FR
      OM timeframes t0_$timeframes WHERE ((t0_$timeframes.organization_id = ?))
      2005-03-02 11:08:33,218 DEBUG [org.jboss.mx.loading.UnifiedClassLoader] New jmx UCL with url null
      2005-03-02 11:08:33,218 DEBUG [org.jboss.mx.loading.UnifiedClassLoader] setRepository, r=org.jboss.mx.loading.HeirarchicalLoaderRepository3@146c0f, ucl=org.jboss.mx
      .loading.UnifiedClassLoader3@9a8200{ url=null ,addedOrder=0}
      2005-03-02 11:08:33,218 DEBUG [org.jboss.mx.loading.UnifiedClassLoader] New jmx UCL with url null
      2005-03-02 11:08:33,218 DEBUG [org.jboss.mx.loading.UnifiedClassLoader] setRepository, r=org.jboss.mx.loading.HeirarchicalLoaderRepository3@146c0f, ucl=org.jboss.mx
      .loading.UnifiedClassLoader3@a4eddb{ url=null ,addedOrder=0}
      2005-03-02 11:08:33,234 DEBUG [org.jboss.mx.loading.UnifiedClassLoader] New jmx UCL with url null
      2005-03-02 11:08:33,234 DEBUG [org.jboss.mx.loading.UnifiedClassLoader] setRepository, r=org.jboss.mx.loading.HeirarchicalLoaderRepository3@146c0f, ucl=org.jboss.mx
      .loading.UnifiedClassLoader3@11eeb20{ url=null ,addedOrder=0}
      2005-03-02 11:08:33,234 DEBUG [org.jboss.mx.loading.UnifiedClassLoader] New jmx UCL with url null
      2005-03-02 11:08:33,234 DEBUG [org.jboss.mx.loading.UnifiedClassLoader] setRepository, r=org.jboss.mx.loading.HeirarchicalLoaderRepository3@146c0f, ucl=org.jboss.mx
      .loading.UnifiedClassLoader3@5a92d5{ url=null ,addedOrder=0}
      2005-03-02 11:08:33,234 DEBUG [org.jboss.ejb.plugins.cmp.jdbc.JDBCLoadEntityCommand.TimeframeEJB] Executing SQL: SELECT timeframe_id, name, organization_id, duratio
      n, start_time, finish_time FROM timeframes WHERE (timeframe_id=?) OR (timeframe_id=?) OR (timeframe_id=?) OR (timeframe_id=?) OR (timeframe_id=?) OR (timeframe_id=?
      ) OR (timeframe_id=?) OR (timeframe_id=?) OR (timeframe_id=?) OR (timeframe_id=?) OR (timeframe_id=?) OR (timeframe_id=?) OR (timeframe_id=?) OR (timeframe_id=?) OR
      (timeframe_id=?) OR (timeframe_id=?) OR (timeframe_id=?) OR (timeframe_id=?) OR (timeframe_id=?) OR (timeframe_id=?)
      2005-03-02 11:08:33,234 DEBUG [org.jboss.ejb.plugins.cmp.jdbc.JDBCLoadEntityCommand.TimeframeEJB] Executing SQL: SELECT timeframe_id, name, organization_id, duratio
      n, start_time, finish_time FROM timeframes WHERE (timeframe_id=?) OR (timeframe_id=?) OR (timeframe_id=?) OR (timeframe_id=?) OR (timeframe_id=?) OR (timeframe_id=?
      ) OR (timeframe_id=?) OR (timeframe_id=?) OR (timeframe_id=?) OR (timeframe_id=?) OR (timeframe_id=?) OR (timeframe_id=?) OR (timeframe_id=?) OR (timeframe_id=?) OR
      (timeframe_id=?) OR (timeframe_id=?) OR (timeframe_id=?) OR (timeframe_id=?) OR (timeframe_id=?) OR (timeframe_id=?)
      2005-03-02 11:08:33,234 DEBUG [org.jboss.ejb.plugins.cmp.jdbc.JDBCLoadEntityCommand.TimeframeEJB] Executing SQL: SELECT timeframe_id, name, organization_id, duratio
      n, start_time, finish_time FROM timeframes WHERE (timeframe_id=?) OR (timeframe_id=?) OR (timeframe_id=?) OR (timeframe_id=?) OR (timeframe_id=?) OR (timeframe_id=?
      ) OR (timeframe_id=?) OR (timeframe_id=?) OR (timeframe_id=?) OR (timeframe_id=?) OR (timeframe_id=?) OR (timeframe_id=?) OR (timeframe_id=?) OR (timeframe_id=?) OR
      (timeframe_id=?) OR (timeframe_id=?) OR (timeframe_id=?) OR (timeframe_id=?) OR (timeframe_id=?) OR (timeframe_id=?)
      2005-03-02 11:08:33,281 DEBUG [Smash] | <ListTimeframeCommand.execute
      ---------------------------------------

      As you can see its 3 equal requests.
      If I'm decrease amount of populates fields - it also decreases amount of request. In other words: count of SQL request equal count of populated fields.

      Is it possible to reduce repeatable reads? Or I must use another approaches.