A concrete deadlock problem

[email protected]
Newsgroups gmane.comp.cms.jahia.devel
Message-ID <OF280B9C1C.CC03CE91-ONC1256F6B.0040034C-C1256F6B.00536580@commaro.com>
We are running Jahia 4.0.4 with the transaction feature switched on and we 
are using an Oracle database. 

The left side navigation box is included by all pages and builds the tree 
with the absoluteContainerList - Tag. After a new page has been released, 
which becomes part of the navigation tree, the first call to the other 
pages inserts a row into the JAHIA_LINK table.

We get the following deadlock situation if requests for two different 
pages comes at the same time:

1st Thread:
calls:
UPDATE jahia_autoids SET jahia_autoids_currentindex=3908 WHERE 
jahia_autoids_tablename='jahia_link'

2nd Thread:
wants to execute the same SQL statement but waits, because the first 
thread did not COMMIT yet

Here is the dtack trace:

OraclePreparedStatement(OracleStatement).doExecuteWithTimeout() line: 2709
OraclePreparedStatement.executeUpdate() line: 589
P6LogPreparedStatement.executeUpdate() line: 183
WrappedPreparedStatement.executeUpdate() line: 324
PreparedStatementWrapper.executeUpdate() line: 71
JahiaIncrementorsDBBaseService.updateLastID(String, int) line: 244
JahiaIncrementorsDBBaseService.autoIncrement(String) line: 100
ObjectLinkDB.createObjectLink(ObjectLink) line: 613
ObjectLink.createLink(ObjectKey, ObjectKey, String, int, Date, String, 
Date, String, Map, Map, Map) line: 76
CrossReferenceManager.setObjectXRef(ObjectKey, ObjectKey) line: 256
ContentPageXRefManager.setPageID(int, int) line: 115
JahiaPageField.load(int, ParamBean) line: 121
JahiaFieldBaseService.loadField(JahiaField, int, ParamBean, 
EntryLoadRequest) line: 811
JahiaFieldBaseService.loadField(int, int, ParamBean, EntryLoadRequest) 
line: 774
ContainerFactory.fullyLoadContainer(JahiaContainer, int, ParamBean, 
EntryLoadRequest, Hashtable, Hashtable, Hashtable) line: 149
ContainerFactoryProxy.load(JahiaContainer, int) line: 137
JahiaContainer.checkProxy(int) line: 870
JahiaContainer.getFields() line: 209
ContainerBean.getFields() line: 212
ContainerBean.isFieldWithCurrentPagePresent() line: 410
ContainerBean.buildActionURIs() line: 381
ContainerBean.getActionURIBeans() line: 300
HTMLToolBox.beginContainerMenu(ContainerBean, String, String, boolean, 
String, String, String, JspWriter) line: 1078
HTMLToolBox.drawBeginActionMenu(Object, String, String, boolean, String, 
String, String, JspWriter) line: 982
ActionMenuTag.doStartTag() line: 121
topic_jsp._jspx_meth_jahiaHtml_actionMenu_2(Tag, PageContext) line: 9386

1st Thread:
continues his operation until the next content:pageField - tag. This one 
gets stuck in the synchronized method JahiaFieldBaseService.loadField, 
because the 2nd thread is in it and can't continue due to the waiting 
database lock. Only a server restart helps now !!!

Here is the stack trace:
JahiaFieldBaseService.loadField(int, int, ParamBean, EntryLoadRequest) 
line: 718
ContainerFactory.fullyLoadContainer(JahiaContainer, int, ParamBean, 
EntryLoadRequest, Hashtable, Hashtable, Hashtable) line: 149
ContainerFactoryProxy.load(JahiaContainer, int) line: 137
JahiaContainer.checkProxy(int) line: 870
JahiaContainer.getField(String) line: 462
PageFieldTag.doStartTag() line: 137
topic_jsp._jspx_meth_content_pageField_2(Tag, PageContext) line: 10743


To solve the problem for now I can only think of using Oracle SEQUENCES 
instead of the jahia_autoids table. The SEQUENCES do not cause locks, but 
unfortunately this is Oracle specific. Another solution would be to call 
the "UPDATE jahia_autoids" in a separate transaction. I don't know yet, if 
this is possible at all.

Why do you need this JAHIA_LINKs anyway? Is it possible to do insert the 
JAHIA_LINKS when releasing the new page?
Do you have any other suggestions how to solve this issue? 

Benjamin Papez
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.