Skip to Content.
Sympa Menu

grouper-dev - RE: [grouper-dev] dbVersionDifferentFields and getAttributeOrNull interraction

Subject: Grouper Developers Forum

List archive

RE: [grouper-dev] dbVersionDifferentFields and getAttributeOrNull interraction


Chronological Thread 
  • From: Chris Hyzer <>
  • To: "" <>
  • Cc: Grouper Dev <>
  • Subject: RE: [grouper-dev] dbVersionDifferentFields and getAttributeOrNull interraction
  • Date: Mon, 16 Mar 2009 01:33:31 -0400
  • Accept-language: en-US
  • Acceptlanguage: en-US

Ive been using dbVersion a bit, and I must say it is not an exact science…  right now dbVersion is meant to be the copy of the data which is committed in the database.

 

It gets confusing when there are multiple operations in one transaction.

 

e.g.  group is created, stored (not committed), updated and committed.

 

On the create, there is no need to worry about dbVersion, it is null.  On the update, the dbVersion is still null.  Maybe the hook wants to know the version of the object on the wire (but not committed), and what has changed in the update… dbVersion will not tell you that  I started to add that to the API to a second dbVersion (transactional state), but it is too confusing I think for users.

 

One of the points of dbVersion is to reduce queries… but the exact DB version (in transaction or out of transaction), is always available by doing a query (in tx or out of).  One point of confusion is a postCommit hook… what does dbVersion mean?  Does it mean the state of the DB before the original edit which initiated the commit, or the tx state before the commit (if situation above where there are multiple updates before commit), or does it mean the current state in the DB (after the commit, but before the hook).  Right now the object is cloned before going to the postCommit, so what you are getting is a point in time [currently of the first option I believe].  But if another postCommit hook edited the group and committed, it would not be reflected…  maybe postCommit in general needs to go to the DB to get the real data so something is not done with stale information (e.g. one hook edits the data, and another edits the original data stepping on the toes of the other hook).

 

Anyways, probably need to think more about the complex cases to make sure there is a way for this to be accurate… 

 

Regards,

Chris

 

 

 

From: Arnaud Deman [mailto:]
Sent: Tuesday, February 17, 2009 11:39 AM
To: Chris Hyzer
Cc: Grouper Dev
Subject: Re: [grouper-dev] dbVersionDifferentFields and getAttributeOrNull interraction

 

Chris,
It works fine !

Thanks again,
Arnaud.



Chris Hyzer a écrit :

Arnaud, thanks for the detailed test case.  Sorry, this is a bug.

 

https://bugs.internet2.edu/jira/browse/GRP-225

 

I fixed this in grouper 1.4 branch, can you get the latest from CVS?

 

cvs -d:pserver::/home/cvs/i2mi login

 

cvs -d:pserver::/home/cvs/i2mi export -r GROUPER_1_4_BRANCH grouper

 

 

There is a test case in grouper and the issue is fixed, now it works.

 

It is a little complex.

 

1. The dbVersion (clone of data) is snapshotted when an object is retrieved from the DB

2. The group attributes (including extension) are not part of the group object, they are a one to many.  Note that in grouper 1.5 the extension is moving to not be an attribute, and is part of the group object.

3. The group attributes are lazy loaded.  So what was occurring was the group was retrieved with null attributes initially, that was copied to the dbVersion, then later on the attributes were lazy loaded from the DB, but the dbVersion of the attributes were never updated (still null).  This is why reading an attribute changed the state of things

4. I changed it so that when the attributes are lazy loaded, if the dbVersion has a null attribute map, it will get updated to whatever was retrieved from the DB.  The test case now works.

 

I believe there is still an issue though, if you read the attributes of the dbVersion and never read the attributes of the real object (not sure why you would do that), I think things would still be out of sync.  I documented that in the Group dbVersion javadoc.  I believe we could figure out a way to link the dbVersion and real object further to fix this issue, but I think the complexity involved to do that for the payoff is not worth it.

 

I will say that the attribute hook would be less complex, so it might be better to use... but not in this case for extension since in 1.5 you will have to move it back to group hook anyway :)

 

Let me know if this works for you.

 

Regards,

Chris




-- 
 
Arnaud Deman
GIP RECIA
Parc d'activités les Aulnaies
151 rue de la Juine - 45160 OLIVET
Tel : 02 38 42 14 63 


  • RE: [grouper-dev] dbVersionDifferentFields and getAttributeOrNull interraction, Chris Hyzer, 03/16/2009

Archive powered by MHonArc 2.6.16.

Top of Page