AnsweredAssumed Answered

attributeService caching incorrectly?

Question asked by aweber1nj on Jul 17, 2012
Latest reply on Jul 18, 2012 by afaust
This is related to my ongoing trials with storing a counter and retrieving it reliably in a behaviour class…

It would appear that the attributeService is attempting to cache values it retrieves, but doing so "incorrectly"?  Note the following log snippet (with threads identified, all starting with "http-8080") :
17 Jul 2012 11:21:13,483 DEBUG http-8080-7 [copyEFRAttrs] Entering getDocSequence for: 56401908-e10e-460d-ac04-588eb9fc9b69
17 Jul 2012 11:21:13,498 INFO  http-8080-23 [copyEFRAttrs] substObjName: ENTERING…
17 Jul 2012 11:21:13,498 DEBUG http-8080-23 [copyEFRAttrs] Entering getDocSequence for: 56401908-e10e-460d-ac04-588eb9fc9b69
17 Jul 2012 11:21:13,498 DEBUG http-8080-5 [copyEFRAttrs] Saved attribute successfully for parent 56401908-e10e-460d-ac04-588eb9fc9b69 = 10
17 Jul 2012 11:21:13,498 DEBUG http-8080-5 [copyEFRAttrs] Leaving getDocSequence
17 Jul 2012 11:21:13,498 DEBUG http-8080-5 [copyEFRAttrs] Sequence set to: 10
17 Jul 2012 11:21:13,498 DEBUG http-8080-7 [copyEFRAttrs] Got value from attribute: 9
If you look at the code in my previous thread (about behaviour threading…will try to link it) it will help explain the logged statements.
Note, specifically:
    Thread -7 tries to enter getDocSequence and pauses to wait for a Lock (still trying this).  So does Thread -23.
    Thread -5 was already in there; it uses attributeService.setAttribute() to update the counter to 10, and releases the lock.
    Thread -7 enters the try-block, does an attributeService.getAttribute(), and gets a stale value: 9.
I don't know what else to do.  It appears that attributeService is returning stale values, and since that is an Alfresco service, I don't have much control over how it operates.

Is there anything I can do to force attributeService to re-fetch from the DB or double-check for stale values?

Thanks again,
AJ

Outcomes