Results 1 to 3 of 3

Thread: Simple Query consuming 100% CPU!

  1. #1
    Join Date
    Feb 2009
    Location
    Tunisia
    Posts
    13

    Unhappy Simple Query consuming 100% CPU!

    Hello!
    I have a Flex Spring application with many datasources (dynamically generated mysql db). I use Hibernate Search for indexing those new databases. This is how i fetch a small dataset:

    Code:
    //get a dynamic session manually
    Session ss = DbManagerMySqlImpl.selectSessionFactory(prefix)
    .getCurrentSession();
    //start a transaction because one of those operations is not applicable out of a transaction
    tx = ss.beginTransaction();
    FullTextQuery  ftq =  Search.getFullTextSession(ss).createFullTextQuery(bq, Abnaux.class);
    //display the boolean query just before executing it
    System.out.println("BQ : "+ bq);
    lst = ftq.setFirstResult(offset) 
    	  .setMaxResults(pageSize)
    	  .list();
    return lst;
    the return lst send the found objects to the flex application through BlazeDs, here is the console trace after this operation (Blazeds logging = all).

    Code:
    BQ : +denomination:hotel
    
    [BlazeDS]Adapter 'java-object' called 'null.rechercher(java.util.Arrays$ArrayList (Collection size:4)
      [0] = null hotel
      [1] = list_fax
      [2] = 0
      [3] = 10
    )'
    [BlazeDS]Result: 'java.util.ArrayList (Collection size:10)
      [0] = xx
      [1] = xx
     ...
      [9] = zz
    '
    then everything is blocked, 100% of cpu is consumed for sometime and then the famous:

    Code:
    [BlazeDS]Java heap space
    java.lang.OutOfMemoryError: Java heap space
    Actually the correct result is fetched and printed on the console, but never sent to the flex application. Can this be a serialization issue?
    Can anyone tell me where this may come from?
    Thanks
    Death is the only valid reason to stop learning

  2. #2
    Join Date
    Feb 2009
    Location
    Tunisia
    Posts
    13

    Arrow Where this exactly happens!

    Hi again,

    While debugging step by step i found that the error occurs in this line in flex.messaging.endpoints.amf.SerializationFilter:

    Code:
    MessageSerializer serializer = sc.newMessageSerializer();
    serializer.initialize(sc, outBuffer, debugTrace);
    serializer.writeMessage(respMesg);//Here the problem occurs
    
    // keep track of serializes bytes for performance metrics
    context.setSerializedBytes(outBuffer.size());
    What seems a bit weird for me, is that before the search operation, i have many lists(other java objects) loaded from the database and steps like the blocked list. All my objects are extending Serializable Class.

    Any ideas?
    Thanks
    Death is the only valid reason to stop learning

  3. #3
    Join Date
    Feb 2009
    Location
    Tunisia
    Posts
    13

    Red face Workaround :(

    I suspected the dynamic session loading, and it was the culprit.
    The problem occurs while serializing data.

    Actually, when trying to access an attached collection (lazily loaded), the access time is about 27s. Luckily, I have a static spring session, loaded from webApplicationCntext.xml, so I detach the object from the dynamic one, close it, and then reattach it to the static session.

    Of course, I can't handle the collection on top (flex), so I managed to get the object by Id(one by one when needed).
    this is actually the unique way I found to fetch my object.

    I Also, tryed the "OpensessionInViewFilter " approach, but it gives the same result.

    I'm not convinced, but it works .

    PS: the approach of Dynamic session is achieved as described here.
    Death is the only valid reason to stop learning

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •