Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[eclipselink-users] ServerSession cache coordination problem

Hello,

I'm experiencing a problem while using session coordination feature of
Eclipselink in a distributed environment on Weblogic 10 cluster. Let's take
the following example. I have two persistent classes in a classical
parent-child relationship:

class Parent {

  private Set<Child> children;
  
  //other fields and methods
}

class Child {

  //parent of type Parent
  private ValueHolderInterface parent = new ValueHolder();
  
  //other fields and methods
}  
 
Collection of children in class Parent is an indirect set (lazy
initialization strategy). Changes in ServerSession cache are replicated
between two nodes using JMS transport and default
ClassDescriptor.SEND_OBJECT_CHANGES propagation strategy.

Recently I discovered that in certain circumstances broken instances of
class Child can be found in ServerSession cache. One of possible paths that
leads to such state is given below:

1. Instance of class Parent is loaded into ServerSession cache on Node1.
2. Lazy collection of children in cached instance of class Parent on Node1
is loaded into memory from database.
3. New instance of class Child is created and assosciated with existing
instance of class Parent on Node2.
4. During the process of UnitOfWork state merging (on Node2) a JMS message
is sent to Node1. This message describes changes that must be propagated to
cache on Node1 in order to maintain consistency of data. Unfortunately
UnitOfWorkChangeSet object which is sent over JMS is incomplete and that
leads to corruption of cache on Node1.

ClassDescriptor.SEND_OBJECT_CHANGES mode of propagation ensures that message
is sent to remote node only if some attributes of existing objects are
changed. In my case the modification of children collection in existing
instance of class Parent triggers cache synchronization message. This
message contains ChangeSet object for a newly created instance of class
Child. However this ChangeSet is not fully populated (it contains
ChangeRecords only for aggregate fields of class Child) and if collection of
children in cached instance of class Parent on Node1 is initialized then a
broken instance of class Child is created and merged into ServerSession
cache on Node1. Only primary key and aggregate fields are populated, other
attributes are NULLs. In consequence when I get this instance of class Child
from cache on Node1 then I encounter NullPointerExceptions accessing null
attributes.

Currently I'm using Eclipselink 2.1.0. The problem started to raise after
switch from Toplink 10.1.3. I suppose that it might be related to this
optimization in Eclipselink:
http://wiki.eclipse.org/EclipseLink/DesignDocs/221546%281.1%29#Avoiding_ChangeSets_for_New_Objects.
ChageSets for new objects are not populated but they are sent to remote
nodes in broken state. I can workaround this problem by changing cache
propagation strategy or maybe also by setting the
ClassDescriptor.shouldUseFullChangeSetsForNewObjects flag to true (not
tested however) but I wonder if this situation is a bug or maybe I miss
something. 

Thanks in advance for help,
Best regards,
Krzysiek

-- 
View this message in context: http://old.nabble.com/ServerSession-cache-coordination-problem-tp31302725p31302725.html
Sent from the EclipseLink - Users mailing list archive at Nabble.com.



Back to the top