[prev in list] [next in list] [prev in thread] [next in thread] 

List:       xmlbeans-user
Subject:    RE: XmlBeans and Synchronization
From:       "Cezar Andrei" <cezar.andrei () oracle ! com>
Date:       2008-10-24 20:45:13
Message-ID: 20081024154513375.00000009248 () CEZAR01
[Download RAW message or body]

Hi Paul,

 =


When doing "local" updates a simple synchronization is done on the synchron=
ization domain of that XMLObject, we call it Locale. By default, each new d=
ocument XMLObject is created with a new Locale. =


 =


But when there is an update operation involving XMLObjects from two Locale-=
s, we're using a Global lock for a short time to get the locks on the two l=
ocales and avoid deadlocks. See code at org.apache.xmlbeans.impl.values.Xml=
ObjectBase.set(XmlObjectBase.java:~2049) .

 =


Most probably your application is doing lot's of set's or the JVM is not op=
timized for this situation. Did you try using a different JVM, 1.6 or JRock=
it? Or you can modify your app to have XMLObjects created in the same Local=
e, this way avoiding GlobalLock.

 =


There is a non backwards compat option, Locale.USE_SAME_LOCALE that can be =
used when creating a new XMLObject to have it created in the same Locale as=
 a different XMLObject.

 =


 =


Cezar

 =


________________________________

From: Paul Hepworth [mailto:Paul.hepworth@detica.com] =

Sent: Friday, October 24, 2008 7:00 AM
To: user@xmlbeans.apache.org; dev@xmlbeans.apache.org
Subject: XmlBeans and Synchronization

 =


Hi (included dev list as this may be too in depth for the user list)

 =


I'm using XmlBeans 2.3.0 in a Weblogic 9.2 J2EE web application (JVM 1.5.0_=
10). We use XmlBeans to compile our schema and these effectively become our=
 domain objects. These are looked up from the DB, stored in the Http Sessio=
n, manipulated from the UI and passed to the DB again.

 =


The application appears to run fine with a single user, however when we tes=
t it with multiple users using LoadRunner, we hit issues.

 =


What we are seeing is that we're getting stuck threads with the following s=
tack:

at java.lang.Object.wait(Native Method)

- waiting on <0xd4a816e8> (a org.apache.xmlbeans.impl.common.Mutex)

at java.lang.Object.wait(Object.java:474)

at org.apache.xmlbeans.impl.common.Mutex.acquire(Mutex.java:33)

- locked <0xd4a816e8> (a org.apache.xmlbeans.impl.common.Mutex)

at org.apache.xmlbeans.impl.common.GlobalLock.acquire(GlobalLock.java:27)

at org.apache.xmlbeans.impl.values.XmlObjectBase.set(XmlObjectBase.java:194=
4)

at ...MyClassImpl.setMyValue(...)

 =


Can anyone shed any light on why this may happen?

 =


More specifically, does anyone know what the synchronisation strategy is in=
 XmlBeans. From my investigation, the GlobalLock uses a static Mutex, which=
 means that if an instance needs to take out more than 1 lock, it attempts =
to acquire a GlobalLock and will subsequently lock out all other threads in=
 the JVM from making any changes to an XmlObject.

 =


If that's the case, it seems very strange that making an update to 1 instan=
ce of an XmlObject would lock out all other threads form updating any other=
 instance of an XmlObject. I would have thought that the synchronisation wo=
uld have solely been around the instance itself.

 =


We have also seen the same issues that have been recorded here: https://iss=
ues.apache.org/jira/browse/XMLBEANS-328

 =


Any help on this would be much appreciated as it's causing major issues!!

Thanks

Paul




This message should be regarded as confidential. If you have received this =
email in error please notify the sender and destroy it immediately.
Statements of intent shall only become binding when confirmed in hard copy =
by an authorised signatory. The contents of this email may relate to dealin=
gs with other companies within the Detica Group plc group of companies.

Detica Limited is registered in England under No: 1337451.

Registered offices: Surrey Research Park, Guildford, Surrey, GU2 7YP, Engla=
nd.


[Attachment #3 (text/html)]

<html xmlns:v="urn:schemas-microsoft-com:vml" \
xmlns:o="urn:schemas-microsoft-com:office:office" \
xmlns:w="urn:schemas-microsoft-com:office:word" \
xmlns:st1="urn:schemas-microsoft-com:office:smarttags" \
xmlns="http://www.w3.org/TR/REC-html40">

<head>
<meta http-equiv=Content-Type content="text/html; charset=us-ascii">
<meta name=Generator content="Microsoft Word 11 (filtered medium)">
<!--[if !mso]>
<style>
v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style>
<![endif]-->
<title>Normal</title>
<o:SmartTagType namespaceuri="urn:schemas-microsoft-com:office:smarttags"
 name="PostalCode"/>
<o:SmartTagType namespaceuri="urn:schemas-microsoft-com:office:smarttags"
 name="City"/>
<o:SmartTagType namespaceuri="urn:schemas-microsoft-com:office:smarttags"
 name="place"/>
<o:SmartTagType namespaceuri="urn:schemas-microsoft-com:office:smarttags"
 name="PlaceName"/>
<o:SmartTagType namespaceuri="urn:schemas-microsoft-com:office:smarttags"
 name="PlaceType"/>
<o:SmartTagType namespaceuri="urn:schemas-microsoft-com:office:smarttags"
 name="country-region"/>
<o:SmartTagType namespaceuri="urn:schemas-microsoft-com:office:smarttags"
 name="PersonName"/>
<!--[if !mso]>
<style>
st1\:*{behavior:url(#default#ieooui) }
</style>
<![endif]-->
<style>
<!--
 /* Font Definitions */
 @font-face
	{font-family:"Lucida Sans";
	panose-1:2 11 6 2 3 5 4 2 2 4;}
@font-face
	{font-family:Tahoma;
	panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
	{font-family:"Book Antiqua";
	panose-1:2 4 6 2 5 3 5 3 3 4;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
	{margin:0in;
	margin-bottom:.0001pt;
	font-size:11.0pt;
	font-family:"Book Antiqua";}
a:link, span.MsoHyperlink
	{color:blue;
	text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
	{color:purple;
	text-decoration:underline;}
p.Code, li.Code, div.Code
	{margin:0in;
	margin-bottom:.0001pt;
	font-size:10.0pt;
	font-family:"Lucida Sans";
	color:navy;}
span.EmailStyle18
	{mso-style-type:personal;
	font-family:Tahoma;
	color:windowtext;
	font-weight:normal;
	font-style:normal;
	text-decoration:none none;}
span.EmailStyle19
	{mso-style-type:personal-reply;
	font-family:Arial;
	color:navy;}
@page Section1
	{size:595.3pt 841.9pt;
	margin:1.0in 1.25in 1.0in 1.25in;}
div.Section1
	{page:Section1;}
-->
</style>

</head>

<body lang=EN-US link=blue vlink=purple>

<div class=Section1>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>Hi Paul,<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>When doing &#8220;local&#8221; updates a
simple synchronization is done on the synchronization domain of that XMLObject,
we call it Locale. By default, each new document XMLObject is created with a
new Locale. <o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>&nbsp;<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>But when there is an update operation
involving XMLObjects from two Locale-s, we&#8217;re using a Global lock for a
short time to get the locks on the two locales and avoid deadlocks. See code at
</span></font><font size=2 face="Courier New"><span lang=EN-GB
style='font-size:10.0pt;font-family:"Courier \
New"'>org.apache.xmlbeans.impl.values.XmlObjectBase.set(XmlObjectBase.java:~2049)</span></font><font
 size=2 color=navy face=Arial><span lang=EN-GB style='font-size:10.0pt;
font-family:Arial;color:navy'> </span></font><font size=2 color=navy
face=Arial><span style='font-size:10.0pt;font-family:Arial;color:navy'>.<o:p></o:p></span></font></p>


<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>Most probably your application is doing
lot&#8217;s of set&#8217;s or the JVM is not optimized for this situation. Did
you try using a different JVM, 1.6 or JRockit? Or you can modify your app to have
XMLObjects created in the same Locale, this way avoiding \
GlobalLock.<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>There is a non backwards compat option,
Locale.USE_SAME_LOCALE that can be used when creating a new XMLObject to have
it created in the same Locale as a different XMLObject.<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>Cezar<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><o:p>&nbsp;</o:p></span></font></p>

<div style='border:none;border-left:solid blue 1.5pt;padding:0in 0in 0in 4.0pt'>

<div>

<div class=MsoNormal align=center style='text-align:center'><font size=3
face="Times New Roman"><span style='font-size:12.0pt;font-family:"Times New Roman"'>

<hr size=2 width="100%" align=center tabindex=-1>

</span></font></div>

<p class=MsoNormal><b><font size=2 face=Tahoma><span style='font-size:10.0pt;
font-family:Tahoma;font-weight:bold'>From:</span></font></b><font size=2
face=Tahoma><span style='font-size:10.0pt;font-family:Tahoma'> Paul Hepworth
[mailto:Paul.hepworth@detica.com] <br>
<b><span style='font-weight:bold'>Sent:</span></b> Friday, October 24, 2008
7:00 AM<br>
<b><span style='font-weight:bold'>To:</span></b> <st1:PersonName \
w:st="on">user@xmlbeans.apache.org</st1:PersonName>; <st1:PersonName \
w:st="on">dev@xmlbeans.apache.org</st1:PersonName><br> <b><span \
style='font-weight:bold'>Subject:</span></b> XmlBeans and \
Synchronization</span></font><font size=3 face="Times New Roman"><span \
style='font-size:12.0pt;font-family:"Times New Roman"'><o:p></o:p></span></font></p>

</div>

<p class=MsoNormal><font size=2 face="Book Antiqua"><span style='font-size:
11.0pt'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Tahoma><span lang=EN-GB style='font-size:
10.0pt;font-family:Tahoma'>Hi (included dev list as this may be too in depth
for the user list)<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Tahoma><span lang=EN-GB style='font-size:
10.0pt;font-family:Tahoma'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Tahoma><span lang=EN-GB style='font-size:
10.0pt;font-family:Tahoma'>I&#8217;m using XmlBeans 2.3.0 in a Weblogic 9.2
J2EE web application (JVM 1.5.0_10). We use XmlBeans to compile our schema and
these effectively become our domain objects. These are looked up from the DB,
stored in the Http Session, manipulated from the UI and passed to the DB \
again.<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Tahoma><span lang=EN-GB style='font-size:
10.0pt;font-family:Tahoma'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Tahoma><span lang=EN-GB style='font-size:
10.0pt;font-family:Tahoma'>The application appears to run fine with a single
user, however when we test it with multiple users using LoadRunner, we hit
issues.<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Tahoma><span lang=EN-GB style='font-size:
10.0pt;font-family:Tahoma'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Tahoma><span lang=EN-GB style='font-size:
10.0pt;font-family:Tahoma'>What we are seeing is that we&#8217;re getting stuck
threads with the following stack:<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face="Courier New"><span lang=EN-GB
style='font-size:10.0pt;font-family:"Courier New"'>at
java.lang.Object.wait(Native Method)<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face="Courier New"><span lang=EN-GB
style='font-size:10.0pt;font-family:"Courier New"'>- waiting on
&lt;0xd4a816e8&gt; (a \
org.apache.xmlbeans.impl.common.Mutex)<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face="Courier New"><span lang=EN-GB
style='font-size:10.0pt;font-family:"Courier New"'>at
java.lang.Object.wait(Object.java:474)<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face="Courier New"><span lang=EN-GB
style='font-size:10.0pt;font-family:"Courier New"'>at
org.apache.xmlbeans.impl.common.Mutex.acquire(Mutex.java:33)<o:p></o:p></span></font></p>


<p class=MsoNormal><font size=2 face="Courier New"><span lang=EN-GB
style='font-size:10.0pt;font-family:"Courier New"'>- locked &lt;0xd4a816e8&gt;
(a org.apache.xmlbeans.impl.common.Mutex)<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face="Courier New"><span lang=EN-GB
style='font-size:10.0pt;font-family:"Courier New"'>at \
org.apache.xmlbeans.impl.common.GlobalLock.acquire(GlobalLock.java:27)<o:p></o:p></span></font></p>


<p class=MsoNormal><font size=2 face="Courier New"><span lang=EN-GB
style='font-size:10.0pt;font-family:"Courier New"'>at
org.apache.xmlbeans.impl.values.XmlObjectBase.set(XmlObjectBase.java:1944)<o:p></o:p></span></font></p>


<p class=MsoNormal><font size=2 face="Courier New"><span lang=EN-GB
style='font-size:10.0pt;font-family:"Courier New"'>at
...MyClassImpl.setMyValue(...)<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face="Courier New"><span lang=EN-GB
style='font-size:10.0pt;font-family:"Courier \
New"'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Tahoma><span lang=EN-GB style='font-size:
10.0pt;font-family:Tahoma'>Can anyone shed any light on why this may \
happen?<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Tahoma><span lang=EN-GB style='font-size:
10.0pt;font-family:Tahoma'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Tahoma><span lang=EN-GB style='font-size:
10.0pt;font-family:Tahoma'>More specifically, does anyone know what the
synchronisation strategy is in XmlBeans. From my investigation, the GlobalLock
uses a static Mutex, which means that if an instance needs to take out more
than 1 lock, it attempts to acquire a GlobalLock and will subsequently lock out
all other threads in the JVM from making any changes to an \
XmlObject.<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Tahoma><span lang=EN-GB style='font-size:
10.0pt;font-family:Tahoma'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Tahoma><span lang=EN-GB style='font-size:
10.0pt;font-family:Tahoma'>If that&#8217;s the case, it seems very strange that
making an update to 1 instance of an XmlObject would lock out all other threads
form updating any other instance of an XmlObject. I would have thought that the
synchronisation would have solely been around the instance \
itself.<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Tahoma><span lang=EN-GB style='font-size:
10.0pt;font-family:Tahoma'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Tahoma><span lang=EN-GB style='font-size:
10.0pt;font-family:Tahoma'>We have also seen the same issues that have been
recorded here: </span></font><span lang=EN-GB><a
href="https://issues.apache.org/jira/browse/XMLBEANS-328">https://issues.apache.org/jira/browse/XMLBEANS-328</a></span><font
 size=2 face=Tahoma><span lang=EN-GB \
style='font-size:10.0pt;font-family:Tahoma'><o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Tahoma><span lang=EN-GB style='font-size:
10.0pt;font-family:Tahoma'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Tahoma><span lang=EN-GB style='font-size:
10.0pt;font-family:Tahoma'>Any help on this would be much appreciated as
it&#8217;s causing major issues!!<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Tahoma><span lang=EN-GB style='font-size:
10.0pt;font-family:Tahoma'>Thanks<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Tahoma><span lang=EN-GB style='font-size:
10.0pt;font-family:Tahoma'>Paul<o:p></o:p></span></font></p>

<p class=MsoNormal style='margin-bottom:12.0pt'><font size=1
face="Times New Roman"><span lang=EN-GB style='font-size:7.5pt;font-family:
"Times New Roman"'><br>
<br>
<br>
This message should be regarded as confidential. If you have received this
email in error please notify the sender and destroy it immediately.<br>
Statements of intent shall only become binding when confirmed in hard copy by
an authorised signatory. The contents of this email may relate to dealings with
other companies within the Detica Group plc group of companies.<br>
<br>
Detica Limited is registered in <st1:country-region w:st="on"><st1:place \
w:st="on">England</st1:place></st1:country-region> under No: 1337451.<br>
<br>
Registered offices: <st1:PlaceName w:st="on">Surrey</st1:PlaceName> <st1:PlaceName
w:st="on">Research</st1:PlaceName> <st1:PlaceType w:st="on">Park</st1:PlaceType>,
Guildford, <st1:place w:st="on"><st1:City w:st="on">Surrey</st1:City>, \
<st1:PostalCode  w:st="on">GU2 7YP</st1:PostalCode>, <st1:country-region \
w:st="on">England</st1:country-region></st1:place>.</span></font><font size=3 \
face="Times New Roman"><span lang=EN-GB style='font-size:12.0pt; font-family:"Times \
New Roman"'><o:p></o:p></span></font></p>

</div>

</div>

</body>

</html>



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic