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(] 18c0e26b-d30a-11dc-97ba-415da2aefe8f
20:15:23,303 http-8080-Processor22 INFO  [org.alfresco.jcr.session.SessionImpl$OuterTransaction.begin(] relying on existing
20:15:24,457 http-8080-Processor22 INFO  [] Wrote out:
<?xml version="1.0" encoding="UTF-8"?>
<Types xmlns="">
  <Override PartName="/skeleton.xml" ContentType="application/plutext-skeleton"/>
20:15:24,475 http-8080-Processor22 INFO  []  made mix:versionable
20:15:24,527 http-8080-Processor22 INFO  [] save() ..
20:15:24,528 http-8080-Processor22 INFO  [org.alfresco.jcr.session.SessionImpl$OuterTransaction.begin(] relying on existing
20:15:24,592 http-8080-Processor22 INFO  [org.alfresco.repo.version.VersionServiceImpl.createVersion(] Creating version.. using$Proxy3
20:15:24,819 http-8080-Processor22 INFO  [org.alfresco.repo.node.db.DbNodeServiceImpl.createAssociation(] creating assocs
20:15:24,994 http-8080-Processor22 INFO  [] 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(] 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  [] Fetching cm:_x005b_Content_Types_x005d_.xml
20:15:34,724 http-8080-Processor22 INFO  [org.docx4j.JcrNodeMapper.AlfrescoJcrNodeMapper.getJcrData(] getting {}content
getting {}content
20:15:34,730 http-8080-Processor22 WARN  [] <?xml version="1.0" encoding="UTF-8"?>
<Types xmlns="">
  <Override ContentType="application/plutext-skeleton" PartName="/skeleton.xml"/>

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(] 2138b389-d30a-11dc-97ba-415da2aefe8f  

20:15:37,699 http-8080-Processor24 WARN  [] <?xml version="1.0" encoding="UTF-8"?>
<Types xmlns="">
   // Where is my data?!

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(] 324f657a-d30a-11dc-97ba-415da2aefe8f

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

Each of the transactions is using RetryingTransactionHelper's doInTransaction.