AnsweredAssumed Answered

session flushed; stale data delivered shortly thereafter

Question asked by jharrop on Feb 4, 2008
Latest reply on Apr 14, 2008 by jharrop
Hi, I need some help please.

I'm finding that after a transaction commits, I have to wait some 5 seconds before the new data is available to a second transaction.

I'd like to understand why this is happening, and whether there is anything I can do to ensure that the state is synchronized with the database immediately  (or if it is, that the second transaction gets the fresh data - though hibernate.cache.use_query_cache=false made no difference).

In this specific case, the first transaction uses JCR to make a node versionable, checks it out, and modifies its contents.  The second transaction tries to read the new contents.

First transaction

20:15:23,299 http-8080-Processor22 INFO  [org.alfresco.jcr.session.SessionImpl.init(SessionImpl.java:191)] 18c0e26b-d30a-11dc-97ba-415da2aefe8f
20:15:23,303 http-8080-Processor22 INFO  [org.alfresco.jcr.session.SessionImpl$OuterTransaction.begin(SessionImpl.java:923)] relying on existing
20:15:24,457 http-8080-Processor22 INFO  [org.plutext.server.io.ChunkingSaveToJCR.save(ChunkingSaveToJCR.java:158)] Wrote out:
<?xml version="1.0" encoding="UTF-8"?>
<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types">
:
  <Override PartName="/skeleton.xml" ContentType="application/plutext-skeleton"/>
:
</Types>
20:15:24,475 http-8080-Processor22 INFO  [org.docx4j.openpackaging.io.SaveToJCR.saveRawXmlPart(SaveToJCR.java:277)]  made mix:versionable
20:15:24,527 http-8080-Processor22 INFO  [org.alfresco.jcr.session.SessionImpl.save(SessionImpl.java:449)] save() ..
20:15:24,528 http-8080-Processor22 INFO  [org.alfresco.jcr.session.SessionImpl$OuterTransaction.begin(SessionImpl.java:923)] relying on existing
20:15:24,592 http-8080-Processor22 INFO  [org.alfresco.repo.version.VersionServiceImpl.createVersion(VersionServiceImpl.java:299)] Creating version.. using$Proxy3
20:15:24,819 http-8080-Processor22 INFO  [org.alfresco.repo.node.db.DbNodeServiceImpl.createAssociation(DbNodeServiceImpl.java:1384)] creating assocs
20:15:24,994 http-8080-Processor22 INFO  [org.docx4j.openpackaging.io.SaveToJCR.saveRawXmlPart(SaveToJCR.java:360)] PUT SUCCESS: [Content_Types].xml(/app:company_home/app:user_homes/sys:Jason_x0027_s_x0020_Home_x0020_Space/cm:FEB27.docx/cm:_x005b_Content_Types_x005d_.xml) VERSION 1.0

20:15:25,575 http-8080-Processor22 INFO  [org.alfresco.repo.node.db.hibernate.HibernateNodeDaoServiceImpl.flush(HibernateNodeDaoServiceImpl.java:340)] flushing

Later in the same transaction, I load that resource again, and the content is as expected (ie its the content I just wrote):

20:15:34,713 http-8080-Processor22 INFO  [org.plutext.server.io.ChunkingLoadFromJCR.deprecatedGetDocumentFromJCRPart(ChunkingLoadFromJCR.java:258)] Fetching cm:_x005b_Content_Types_x005d_.xml
20:15:34,724 http-8080-Processor22 INFO  [org.docx4j.JcrNodeMapper.AlfrescoJcrNodeMapper.getJcrData(AlfrescoJcrNodeMapper.java:50)] getting {http://www.alfresco.org/model/content/1.0}content
getting {http://www.alfresco.org/model/content/1.0}content
20:15:34,730 http-8080-Processor22 WARN  [org.docx4j.openpackaging.io.Load.debugPrint(Load.java:54)] <?xml version="1.0" encoding="UTF-8"?>
<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types">
:
  <Override ContentType="application/plutext-skeleton" PartName="/skeleton.xml"/>
:
</Types>

Second transaction

But next, in a new session - 2.7 sec later - the data retrieved is what it was before the first transaction took place:

20:15:37,478 http-8080-Processor24 INFO  [org.alfresco.jcr.session.SessionImpl.init(SessionImpl.java:191)] 2138b389-d30a-11dc-97ba-415da2aefe8f  

20:15:37,699 http-8080-Processor24 WARN  [org.docx4j.openpackaging.io.Load.debugPrint(Load.java:54)] <?xml version="1.0" encoding="UTF-8"?>
  
<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types">
:
   // Where is my data?!
:
</Types>

Third transaction

But if you wait a little bit longer  - 5 secs is enough - and a new session can see the results of the first transaction.

20:16:06,168 http-8080-Processor24 INFO  [org.alfresco.jcr.session.SessionImpl.init(SessionImpl.java:191)] 324f657a-d30a-11dc-97ba-415da2aefe8f

20:16:06,304 http-8080-Processor24 INFO  [org.alfresco.repo.webdav.plutext.GetMethod.executeImpl(GetMethod.java:300)] 1.0
20:16:06,312 http-8080-Processor24 INFO  [org.alfresco.repo.webdav.plutext.GetMethod.executeImpl(GetMethod.java:301)] <Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types"><Default ContentType="application/vnd.openxmlformats-package.relationships+xml" Extension="rels" />
:
    <Override ContentType="application/plutext-skeleton" PartName="/skeleton.xml" />
:
</Types>

Each of the transactions is using RetryingTransactionHelper's doInTransaction.

thanks

Jason

Outcomes