Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [CDO] exceptions occur whereas they are handled in a try/catch clause
[CDO] exceptions occur whereas they are handled in a try/catch clause [message #532562] Mon, 10 May 2010 13:11 Go to next message
Jeremie B. is currently offline Jeremie B.Friend
Messages: 1
Registered: May 2010
Junior Member
Hi, I'm new with CDO programming. Here is my case:

I have 10 threaded clients committing around 10 updates each (loop) at the same time: kind of a flood. I manage exceptions by using rollback() operation inside the try/catch clause (see simplified extract 1 below). The test works!

Nevertheless, exceptions still appear in the console view of the clients (see extract 2 & 3 below). One seems to be related with rollback operation, while the other is about synchronization.
At least I would like to avoid those exceptions on the client, any idea ?

To avoid the first exception, I tried using cdoWriteLock() operations in order to protect the used elements. But it doesn't seem to be adapted to my case.
I'm also wondering the purpose of the listeners (IListener), can I find an interest there in order to get the clients up to date?

		//init
		session = openSession();
		CDOTransaction transaction = session.openTransaction();
		CDOResource resource = transaction.getResource("/res1");
		Library l=null,l2=null;
		String s=null;
		int marker;
		Model m=(Model)resource.getContents().get(0);
		
		//process
		for (int i=0;i<10;i++)
		{
			l=m.getLibraries().get(0);
			l2=m.getLibraries().get(1);
			marker=0;

			//loop until the commit pass
			while (marker==0)
			{
				try 
				{
					s=l.getName();
					l.setName(l2.getName());
					l2.setName(s);
					transaction.commit();
					marker=1;
				}
				catch (Exception e)
				{
					transaction.rollback();
					System.out.println("/!\\ Rollback /!\\ ");
				}
			}
		}
		
		//end
		transaction.close();
		session.close();


[ERROR] Rollback in DBStore: java.util.ConcurrentModificationException: Attempt by Transaction[128:1] to modify historical revision: Library@OID74277:0v3
	at org.eclipse.emf.cdo.internal.server.TransactionCommitContext.computeDirtyObject(TransactionCommitContext.java:585)
	at org.eclipse.emf.cdo.internal.server.TransactionCommitContext.computeDirtyObjects(TransactionCommitContext.java:556)
	at org.eclipse.emf.cdo.internal.server.TransactionCommitContext.write(TransactionCommitContext.java:291)
	at org.eclipse.emf.cdo.spi.server.InternalCommitContext$1.runLoop(InternalCommitContext.java:35)
	at org.eclipse.emf.cdo.spi.server.InternalCommitContext$1.runLoop(InternalCommitContext.java:1)
	at org.eclipse.net4j.util.om.monitor.ProgressDistributor.run(ProgressDistributor.java:96)
	at org.eclipse.emf.cdo.server.internal.net4j.protocol.CommitTransactionIndication.indicatingCommit(CommitTransactionIndication.java:286)
	at org.eclipse.emf.cdo.server.internal.net4j.protocol.CommitTransactionIndication.indicating(CommitTransactionIndication.java:164)
	at org.eclipse.emf.cdo.server.internal.net4j.protocol.CommitTransactionIndication.indicating(CommitTransactionIndication.java:118)
	at org.eclipse.net4j.signal.IndicationWithMonitoring.indicating(IndicationWithMonitoring.java:84)
	at org.eclipse.net4j.signal.IndicationWithResponse.doExtendedInput(IndicationWithResponse.java:90)
	at org.eclipse.net4j.signal.Signal.doInput(Signal.java:311)
	at org.eclipse.net4j.signal.IndicationWithResponse.execute(IndicationWithResponse.java:63)
	at org.eclipse.net4j.signal.IndicationWithMonitoring.execute(IndicationWithMonitoring.java:63)
	at org.eclipse.net4j.signal.Signal.runSync(Signal.java:238)
	at org.eclipse.net4j.signal.Signal.run(Signal.java:146)
	at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at java.lang.Thread.run(Unknown Source)


[ERROR] Not active: SignalProtocol[cdo]
java.lang.IllegalStateException: Not active: SignalProtocol[cdo]
	at org.eclipse.net4j.util.lifecycle.LifecycleUtil.checkActive(LifecycleUtil.java:71)
	at org.eclipse.net4j.signal.Signal.getProtocol(Signal.java:88)
	at org.eclipse.emf.cdo.internal.net4j.protocol.CDOClientIndication.getProtocol(CDOClientIndication.java:45)
	at org.eclipse.emf.cdo.internal.net4j.protocol.CDOClientIndication.getProtocol(CDOClientIndication.java:1)
	at org.eclipse.net4j.signal.Signal.runSync(Signal.java:250)
	at org.eclipse.net4j.signal.Signal.run(Signal.java:146)
	at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at java.lang.Thread.run(Unknown Source)
[INFO] Commit notification arrived while session is inactive
Re: [CDO] exceptions occur whereas they are handled in a try/catch clause [message #533047 is a reply to message #532562] Wed, 12 May 2010 06:11 Go to previous message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6682
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------000401070106030300040607
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit

Hi Jeremie,

Comments below...


Am 10.05.2010 15:11, schrieb Jeremie B.:
> Hi, I'm new with CDO programming. Here is my case:
> I have 10 threaded clients committing around 10 updates each (loop) at
> the same time: kind of a flood. I manage exceptions by using
> rollback() operation inside the try/catch clause (see simplified
> extract 1 below). The test works!
>
> Nevertheless, exceptions still appear in the console view of the
> clients (see extract 2 & 3 below). One seems to be related with
> rollback operation,
Yes, there was an attempt to modify a version of an object that has
already been modified by another transaction.

> while the other is about synchronization.
Roughly. It's caused by *normal* race conditions in *asynchronous*
shutdown signalling. Nothing the client should be worried about.

> At least I would like to avoid those exceptions on the client, any idea ?
You mean avoid *logging* these exceptions? All exceptions are usually
logged by bundles via OM.LOG.error(ex) and you can not prevent that from
happening. The only thing you could try is to remove or customize the
OMLogHandler that annoys you, in this case probably the
org.eclipse.net4j.util.om.log.PrintLogHandler.CONSOLE:

| OMPlatform.INSTANCE.removeLogHandler(PrintLogHandler.CONSOLE );|



>
> To avoid the first exception, I tried using cdoWriteLock() operations
> in order to protect the used elements.
Note that you decrease performance and concurrency with these
pessimistic locks. You should carefully measure the ratio between "good"
and "bad" commits without locks and see if it justifies a pessimistic
strategy.

> But it doesn't seem to be adapted to my case.
What do you mean by this?

> I'm also wondering the purpose of the listeners (IListener),
IListeners listen for IEvents of the components they're registered with.
Which events are you talking about? There are a lot of them ;-)

> can I find an interest there in order to get the clients up to date?
Hmm, I don't understand this question. Please reword it for me.

>
> //init
> session = openSession();
> CDOTransaction transaction = session.openTransaction();
> CDOResource resource = transaction.getResource("/res1");
> Library l=null,l2=null;
> String s=null;
> int marker;
> Model m=(Model)resource.getContents().get(0);
>
> //process
> for (int i=0;i<10;i++)
> {
> l=m.getLibraries().get(0);
> l2=m.getLibraries().get(1);
> marker=0;
>
> //loop until the commit pass
> while (marker==0)
> {
> try {
> s=l.getName();
> l.setName(l2.getName());
> l2.setName(s);
> transaction.commit();
> marker=1;
> }
> catch (Exception e)
> {
> transaction.rollback();
> System.out.println("/!\\ Rollback /!\\ ");
> }
> }
> }
>
> //end
> transaction.close();
> session.close();
This code looks good to me. Are you really only talking about the
logging in the console?

Cheers
/Eike

----
http://thegordian.blogspot.com
http://twitter.com/eikestepper


>
> [ERROR] Rollback in DBStore:
> java.util.ConcurrentModificationException: Attempt by
> Transaction[128:1] to modify historical revision: Library@OID74277:0v3
> at
> org.eclipse.emf.cdo.internal.server.TransactionCommitContext .computeDirtyObject(TransactionCommitContext.java:585)
>
> at
> org.eclipse.emf.cdo.internal.server.TransactionCommitContext .computeDirtyObjects(TransactionCommitContext.java:556)
>
> at
> org.eclipse.emf.cdo.internal.server.TransactionCommitContext .write(TransactionCommitContext.java:291)
>
> at
> org.eclipse.emf.cdo.spi.server.InternalCommitContext$1.runLo op(InternalCommitContext.java:35)
>
> at
> org.eclipse.emf.cdo.spi.server.InternalCommitContext$1.runLo op(InternalCommitContext.java:1)
>
> at
> org.eclipse.net4j.util.om.monitor.ProgressDistributor.run(Pr ogressDistributor.java:96)
>
> at
> org.eclipse.emf.cdo.server.internal.net4j.protocol.CommitTra nsactionIndication.indicatingCommit(CommitTransactionIndicat ion.java:286)
>
> at
> org.eclipse.emf.cdo.server.internal.net4j.protocol.CommitTra nsactionIndication.indicating(CommitTransactionIndication.ja va:164)
>
> at
> org.eclipse.emf.cdo.server.internal.net4j.protocol.CommitTra nsactionIndication.indicating(CommitTransactionIndication.ja va:118)
>
> at
> org.eclipse.net4j.signal.IndicationWithMonitoring.indicating (IndicationWithMonitoring.java:84)
>
> at
> org.eclipse.net4j.signal.IndicationWithResponse.doExtendedIn put(IndicationWithResponse.java:90)
>
> at org.eclipse.net4j.signal.Signal.doInput(Signal.java:311)
> at
> org.eclipse.net4j.signal.IndicationWithResponse.execute(Indi cationWithResponse.java:63)
>
> at
> org.eclipse.net4j.signal.IndicationWithMonitoring.execute(In dicationWithMonitoring.java:63)
>
> at org.eclipse.net4j.signal.Signal.runSync(Signal.java:238)
> at org.eclipse.net4j.signal.Signal.run(Signal.java:146)
> at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unkno wn
> Source)
> at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
> at java.lang.Thread.run(Unknown Source)
>
> [ERROR] Not active: SignalProtocol[cdo]
> java.lang.IllegalStateException: Not active: SignalProtocol[cdo]
> at
> org.eclipse.net4j.util.lifecycle.LifecycleUtil.checkActive(L ifecycleUtil.java:71)
>
> at org.eclipse.net4j.signal.Signal.getProtocol(Signal.java:88)
> at
> org.eclipse.emf.cdo.internal.net4j.protocol.CDOClientIndicat ion.getProtocol(CDOClientIndication.java:45)
>
> at
> org.eclipse.emf.cdo.internal.net4j.protocol.CDOClientIndicat ion.getProtocol(CDOClientIndication.java:1)
>
> at org.eclipse.net4j.signal.Signal.runSync(Signal.java:250)
> at org.eclipse.net4j.signal.Signal.run(Signal.java:146)
> at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unkno wn
> Source)
> at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
> at java.lang.Thread.run(Unknown Source)
> [INFO] Commit notification arrived while session is inactive

--------------000401070106030300040607
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 8bit

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Hi Jeremie,<br>
<br>
Comments below...<br>
<br>
<br>
Am 10.05.2010 15:11, schrieb Jeremie B.:
<blockquote cite="mid:hs90m7$80c$1@build.eclipse.org" type="cite">Hi,
I'm new with CDO programming. Here is my case: <br>
I have 10 threaded clients committing around 10 updates each (loop) at
the same time: kind of a flood. I manage exceptions by using rollback()
operation inside the try/catch clause (see simplified extract 1 below).
The test works!
<br>
<br>
Nevertheless, exceptions still appear in the console view of the
clients (see extract 2 &amp; 3 below). One seems to be related with
rollback operation,</blockquote>
Yes, there was an attempt to modify a version of an object that has
already been modified by another transaction.<br>
<br>
<blockquote cite="mid:hs90m7$80c$1@build.eclipse.org" type="cite">
while the other is about synchronization.
<br>
</blockquote>
Roughly. It's caused by *normal* race conditions in *asynchronous*
shutdown signalling. Nothing the client should be worried about.<br>
<br>
<blockquote cite="mid:hs90m7$80c$1@build.eclipse.org" type="cite">At
least I would like to avoid those exceptions on the client, any idea ?
<br>
</blockquote>
You mean avoid *logging* these exceptions? All exceptions are usually
logged by bundles via OM.LOG.error(ex) and you can not prevent that
from happening. The only thing you could try is to remove or customize
the OMLogHandler that annoys you, in this case probably the
org.eclipse.net4j.util.om.log.PrintLogHandler.CONSOLE:<br>
<br>
<title></title>
<style type="text/css">
<!--code { font-family: Courier New, Courier; font-size: 10pt; margin: 0px; }-->
</style>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<!-- ======================================================== -->
<!-- = Java Sourcecode to HTML automatically converted code = --><!-- = Java2Html Converter 5.0 [2006-02-26] by Markus Gebhard markus@jave.de = -->
<!-- = Further information: http://www.java2html.de = -->
<div class="java" align="left">
<table bgcolor="#ffffff" border="0" cellpadding="3" cellspacing="0">
<tbody>
<tr>
<!-- start source code --> <td align="left" nowrap="nowrap"
valign="top"> <code><font color="#ffffff">    </font><font
color="#000000">OMPlatform.INSTANCE.removeLogHandler</font ><font
color="#000000">(</font><font color="#000000">PrintLogHandler.CONSOLE</font><font
color="#000000">)</font><font color="#000000">;</font></code> </td>
<!-- end source code --> </tr>
</tbody>
</table>
</div>
<!-- = END of automatically generated HTML code = -->
<!-- ======================================================== --><br>
<br>
<blockquote cite="mid:hs90m7$80c$1@build.eclipse.org" type="cite"><br>
To avoid the first exception, I tried using cdoWriteLock() operations
in order to protect the used elements. </blockquote>
Note that you decrease performance and concurrency with these
pessimistic locks. You should carefully measure the ratio between
"good" and "bad" commits without locks and see if it justifies a
pessimistic strategy.<br>
<br>
<blockquote cite="mid:hs90m7$80c$1@build.eclipse.org" type="cite">But
it doesn't seem to be adapted to my case. </blockquote>
What do you mean by this?<br>
<br>
<blockquote cite="mid:hs90m7$80c$1@build.eclipse.org" type="cite">I'm
also wondering the purpose of the listeners (IListener),</blockquote>
IListeners listen for IEvents of the components they're registered
with. Which events are you talking about? There are a lot of them ;-)<br>
<br>
<blockquote cite="mid:hs90m7$80c$1@build.eclipse.org" type="cite"> can
I find an interest there in order to get the clients up to date?
<br>
</blockquote>
Hmm, I don't understand this question. Please reword it for me.<br>
<br>
<blockquote cite="mid:hs90m7$80c$1@build.eclipse.org" type="cite"><br>
        //init
<br>
        session = openSession();
<br>
        CDOTransaction transaction = session.openTransaction();
<br>
        CDOResource resource = transaction.getResource("/res1");
<br>
        Library l=null,l2=null;
<br>
        String s=null;
<br>
        int marker;
<br>
        Model m=(Model)resource.getContents().get(0);
<br>
        <br>
        //process
<br>
        for (int i=0;i&lt;10;i++)
<br>
        {
<br>
            l=m.getLibraries().get(0);
<br>
            l2=m.getLibraries().get(1);
<br>
            marker=0;
<br>
<br>
            //loop until the commit pass
<br>
            while (marker==0)
<br>
            {
<br>
                try                 {
<br>
                    s=l.getName();
<br>
                    l.setName(l2.getName());
<br>
                    l2.setName(s);
<br>
                    transaction.commit();
<br>
                    marker=1;
<br>
                }
<br>
                catch (Exception e)
<br>
                {
<br>
                    transaction.rollback();
<br>
                    System.out.println("/!\\ Rollback /!\\ ");
<br>
                }
<br>
            }
<br>
        }
<br>
        <br>
        //end
<br>
        transaction.close();
<br>
        session.close();
<br>
</blockquote>
This code looks good to me. Are you really only talking about the
logging in the console?<br>
<br>
Cheers<br>
/Eike<br>
<br>
----<br>
<a class="moz-txt-link-freetext" href="http://thegordian.blogspot.com">http://thegordian.blogspot.com</a><br>
<a class="moz-txt-link-freetext" href="http://twitter.com/eikestepper">http://twitter.com/eikestepper</a><br>
<br>
<br>
<blockquote cite="mid:hs90m7$80c$1@build.eclipse.org" type="cite"><br>
[ERROR] Rollback in DBStore: java.util.ConcurrentModificationException:
Attempt by Transaction[128:1] to modify historical revision:
Library@OID74277:0v3
<br>
    at
org.eclipse.emf.cdo.internal.server.TransactionCommitContext .computeDirtyObject(TransactionCommitContext.java:585)
<br>
    at
org.eclipse.emf.cdo.internal.server.TransactionCommitContext .computeDirtyObjects(TransactionCommitContext.java:556)
<br>
    at
org.eclipse.emf.cdo.internal.server.TransactionCommitContext .write(TransactionCommitContext.java:291)
<br>
    at
org.eclipse.emf.cdo.spi.server.InternalCommitContext$1.runLo op(InternalCommitContext.java:35)
<br>
    at
org.eclipse.emf.cdo.spi.server.InternalCommitContext$1.runLo op(InternalCommitContext.java:1)
<br>
    at
org.eclipse.net4j.util.om.monitor.ProgressDistributor.run(Pr ogressDistributor.java:96)
<br>
    at
org.eclipse.emf.cdo.server.internal.net4j.protocol.CommitTra nsactionIndication.indicatingCommit(CommitTransactionIndicat ion.java:286)
<br>
    at
org.eclipse.emf.cdo.server.internal.net4j.protocol.CommitTra nsactionIndication.indicating(CommitTransactionIndication.ja va:164)
<br>
    at
org.eclipse.emf.cdo.server.internal.net4j.protocol.CommitTra nsactionIndication.indicating(CommitTransactionIndication.ja va:118)
<br>
    at
org.eclipse.net4j.signal.IndicationWithMonitoring.indicating (IndicationWithMonitoring.java:84)
<br>
    at
org.eclipse.net4j.signal.IndicationWithResponse.doExtendedIn put(IndicationWithResponse.java:90)
<br>
    at org.eclipse.net4j.signal.Signal.doInput(Signal.java:311)
<br>
    at
org.eclipse.net4j.signal.IndicationWithResponse.execute(Indi cationWithResponse.java:63)
<br>
    at
org.eclipse.net4j.signal.IndicationWithMonitoring.execute(In dicationWithMonitoring.java:63)
<br>
    at org.eclipse.net4j.signal.Signal.runSync(Signal.java:238)
<br>
    at org.eclipse.net4j.signal.Signal.run(Signal.java:146)
<br>
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unkno wn
Source)
<br>
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown
Source)
<br>
    at java.lang.Thread.run(Unknown Source)
<br>
<br>
[ERROR] Not active: SignalProtocol[cdo]
<br>
java.lang.IllegalStateException: Not active: SignalProtocol[cdo]
<br>
    at
org.eclipse.net4j.util.lifecycle.LifecycleUtil.checkActive(L ifecycleUtil.java:71)
<br>
    at org.eclipse.net4j.signal.Signal.getProtocol(Signal.java:88)
<br>
    at
org.eclipse.emf.cdo.internal.net4j.protocol.CDOClientIndicat ion.getProtocol(CDOClientIndication.java:45)
<br>
    at
org.eclipse.emf.cdo.internal.net4j.protocol.CDOClientIndicat ion.getProtocol(CDOClientIndication.java:1)
<br>
    at org.eclipse.net4j.signal.Signal.runSync(Signal.java:250)
<br>
    at org.eclipse.net4j.signal.Signal.run(Signal.java:146)
<br>
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unkno wn
Source)
<br>
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown
Source)
<br>
    at java.lang.Thread.run(Unknown Source)
<br>
[INFO] Commit notification arrived while session is inactive
<br>
</blockquote>
</body>
</html>

--------------000401070106030300040607--


Previous Topic:how to save a list of DataObjects linked to another DataObject
Next Topic:[CDO] CDO server bundles deployed in Tomcat via servletbridge
Goto Forum:
  


Current Time: Fri Apr 19 10:50:20 GMT 2024

Powered by FUDForum. Page generated in 0.02041 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top