Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [CDO] Problem with CDOXATransaction
[CDO] Problem with CDOXATransaction [message #487415] Wed, 23 September 2009 07:34 Go to next message
Eclipse UserFriend
Originally posted by: adomas.greicius.nomagic.com

Hello,
I have wrote test. It has never ending commit on CDOXATransaction. I want
to ask is it right to use CDOXATransaction which has same resource loaded in
two transaction ?

Adomas



package com.nomagic.cdo.test.tests;


import org.eclipse.emf.cdo.eresource.CDOResource;

import org.eclipse.emf.cdo.session.CDOSession;

import org.eclipse.emf.cdo.tests.AbstractCDOTest;

import org.eclipse.emf.cdo.tests.model1.Category;

import org.eclipse.emf.cdo.tests.model1.Company;

import org.eclipse.emf.cdo.transaction.CDOTransaction;

import org.eclipse.emf.cdo.transaction.CDOXATransaction;

import org.eclipse.emf.cdo.util.CDOUtil;

import org.eclipse.emf.cdo.view.CDOViewSet;


public class TestDistributedTransactions extends AbstractCDOTest {

public void testComparisonAcrossTransactions() throws Exception {


Company company1 = getModel1Factory().createCompany();

company1.setName("Your daddy");


for (int i = 0; i < 10; i++) {

Category category = getModel1Factory().createCategory();

company1.getCategories().add(category);

}


CDOSession session = openModel1Session();

CDOTransaction transaction = session.openTransaction();


CDOViewSet viewSet1 = transaction.getViewSet();

CDOXATransaction cdoxaTransaction = CDOUtil.createXATransaction();

cdoxaTransaction.add(viewSet1);


CDOResource res = transaction.getOrCreateResource("/res1");

res.getContents().clear();


transaction.commit();

res.getContents().add(company1);

transaction.commit();


assertEquals(10, company1.getCategories().size());


CDOSession session2 = openModel1Session();

CDOTransaction transaction2 = session2.openTransaction();


CDOViewSet viewSet2 = transaction2.getViewSet();

cdoxaTransaction.add(viewSet2);


CDOResource res2 = transaction2.getOrCreateResource("/res2");


Category tempCategory = getModel1Factory().createCategory();


company1.getCategories().add(tempCategory);


res2.getContents().add(tempCategory);


cdoxaTransaction.commit();


System.out.println("Done");

}

}
Re: [CDO] Problem with CDOXATransaction [message #487438 is a reply to message #487415] Wed, 23 September 2009 09:35 Go to previous messageGo to next message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6682
Registered: July 2009
Senior Member
Hi Adomas,

Good question! I suspect that it *could* be problematic if the same
objects get modified, a conflict thereby introduced. I hope that Simon
knows the exact answer.

In any case an XA commit should terminate somehow after a finite amount
of time (that is somehow related to the total transaction size).

Cheers
/Eike

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



Adomas Greicius schrieb:
> Hello,
> I have wrote test. It has never ending commit on CDOXATransaction. I want
> to ask is it right to use CDOXATransaction which has same resource loaded in
> two transaction ?
>
> Adomas
>
>
>
> package com.nomagic.cdo.test.tests;
>
>
> import org.eclipse.emf.cdo.eresource.CDOResource;
>
> import org.eclipse.emf.cdo.session.CDOSession;
>
> import org.eclipse.emf.cdo.tests.AbstractCDOTest;
>
> import org.eclipse.emf.cdo.tests.model1.Category;
>
> import org.eclipse.emf.cdo.tests.model1.Company;
>
> import org.eclipse.emf.cdo.transaction.CDOTransaction;
>
> import org.eclipse.emf.cdo.transaction.CDOXATransaction;
>
> import org.eclipse.emf.cdo.util.CDOUtil;
>
> import org.eclipse.emf.cdo.view.CDOViewSet;
>
>
> public class TestDistributedTransactions extends AbstractCDOTest {
>
> public void testComparisonAcrossTransactions() throws Exception {
>
>
> Company company1 = getModel1Factory().createCompany();
>
> company1.setName("Your daddy");
>
>
> for (int i = 0; i < 10; i++) {
>
> Category category = getModel1Factory().createCategory();
>
> company1.getCategories().add(category);
>
> }
>
>
> CDOSession session = openModel1Session();
>
> CDOTransaction transaction = session.openTransaction();
>
>
> CDOViewSet viewSet1 = transaction.getViewSet();
>
> CDOXATransaction cdoxaTransaction = CDOUtil.createXATransaction();
>
> cdoxaTransaction.add(viewSet1);
>
>
> CDOResource res = transaction.getOrCreateResource("/res1");
>
> res.getContents().clear();
>
>
> transaction.commit();
>
> res.getContents().add(company1);
>
> transaction.commit();
>
>
> assertEquals(10, company1.getCategories().size());
>
>
> CDOSession session2 = openModel1Session();
>
> CDOTransaction transaction2 = session2.openTransaction();
>
>
> CDOViewSet viewSet2 = transaction2.getViewSet();
>
> cdoxaTransaction.add(viewSet2);
>
>
> CDOResource res2 = transaction2.getOrCreateResource("/res2");
>
>
> Category tempCategory = getModel1Factory().createCategory();
>
>
> company1.getCategories().add(tempCategory);
>
>
> res2.getContents().add(tempCategory);
>
>
> cdoxaTransaction.commit();
>
>
> System.out.println("Done");
>
> }
>
> }
>
>
>
>


Re: [CDO] Problem with CDOXATransaction [message #487462 is a reply to message #487415] Wed, 23 September 2009 10:53 Go to previous messageGo to next message
Simon Mc Duff is currently offline Simon Mc DuffFriend
Messages: 596
Registered: July 2009
Senior Member
Hi Adomas,

I never tried it but Like Eike told us... it could be a problem.

Maybe we should force that it is never used that way.. since problem could occured.(changing the same object.. will always fail anyway... maybe if you put a good conflictresolver it will not Smile!)

Can you paste the stack trace of the thread that hangs?


Simon


Re: [CDO] Problem with CDOXATransaction [message #487479 is a reply to message #487415] Wed, 23 September 2009 11:53 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: adomas.greicius.nomagic.com

Hello Simon

This is stack trace.

Thread [main] (Suspended)
Unsafe.park(boolean, long) line: not available [native method]
LockSupport.parkNanos(long) line: 146
FutureTask$Sync(AbstractQueuedSynchronizer).doAcquireSharedN anos(int, long)
line: 912
FutureTask$Sync(AbstractQueuedSynchronizer).tryAcquireShared Nanos(int,
long) line: 1201
FutureTask$Sync.innerGet(long) line: 210
FutureTask<V>.get(long, TimeUnit) line: 85
CDOXATransactionImpl.send(Collection<CDOXACommitContextImpl >,
IProgressMonitor) line: 212
CDOXATransactionImpl.commit(IProgressMonitor) line: 275
CDOXATransactionImpl.commit() line: 253
TestDistributedTransactions.testComparisonAcrossTransactions () line: 55
NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not
available [native method]
NativeMethodAccessorImpl.invoke(Object, Object[]) line: 39
DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 25
Method.invoke(Object, Object...) line: 585
TestDistributedTransactions(TestCase).runTest() line: 164
TestDistributedTransactions(TestCase).runBare() line: 130
TestDistributedTransactions(AbstractOMTest).runBare() line: 109
TestResult$1.protect() line: 106
TestResult.runProtected(Test, Protectable) line: 124
TestResult.run(TestCase) line: 109
TestDistributedTransactions(TestCase).run(TestResult) line: 120
TestDistributedTransactions(AbstractOMTest).run(TestResult) line: 131
TestSuite.runTest(Test, TestResult) line: 230
TestSuite.run(TestResult) line: 225
JUnit3TestReference.run(TestExecution) line: 130
TestExecution.run(ITestReference[]) line: 38
RemotePluginTestRunner(RemoteTestRunner).runTests(String[], String,
TestExecution) line: 460
RemotePluginTestRunner(RemoteTestRunner).runTests(TestExecut ion) line: 673
RemotePluginTestRunner(RemoteTestRunner).run() line: 386
RemotePluginTestRunner.main(String[]) line: 62
CoreTestApplication.run(Object) line: 23
NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not
available [native method]
NativeMethodAccessorImpl.invoke(Object, Object[]) line: 39
DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 25
Method.invoke(Object, Object...) line: 585
EclipseAppContainer.callMethodWithException(Object, String, Class[],
Object[]) line: 574
EclipseAppHandle.run(Object) line: 195
EclipseAppLauncher.runApplication(Object) line: 110
EclipseAppLauncher.start(Object) line: 79
EclipseStarter.run(Object) line: 386
EclipseStarter.run(String[], Runnable) line: 179
NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not
available [native method]
NativeMethodAccessorImpl.invoke(Object, Object[]) line: 39
DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 25
Method.invoke(Object, Object...) line: 585
Main.invokeFramework(String[], URL[]) line: 549
Main.basicRun(String[]) line: 504
Main.run(String[]) line: 1236
Main.main(String[]) line: 1212


Other thread

Thread [pool-3-thread-4] (Suspended)
MEMStoreAccessor.write(IStoreAccessor$CommitContext, OMMonitor) line: 195
XATransactionCommitContext(TransactionCommitContextImpl).wri te(OMMonitor)
line: 269
XATransactionCommitContext.write(OMMonitor) line: 69
CommitManager$TransactionCommitContextEntry$1.call() line: 163
FutureTask$Sync.innerRun() line: 269 [local variables unavailable]
FutureTask<V>.run() line: 123
ThreadPoolExecutor$Worker.runTask(Runnable) line: 650
ThreadPoolExecutor$Worker.run() line: 675
Thread.run() line: 595

Can I help you with smth else? I think that this situaction should easy
reproduse on you computers.

"Adomas Greicius" <adomas.greicius@nomagic.com> wrote in message
news:h9cj20$6gu$1@build.eclipse.org...
> Hello,
> I have wrote test. It has never ending commit on CDOXATransaction. I want
> to ask is it right to use CDOXATransaction which has same resource loaded
> in two transaction ?
>
> Adomas
>
>
>
> package com.nomagic.cdo.test.tests;
>
>
> import org.eclipse.emf.cdo.eresource.CDOResource;
>
> import org.eclipse.emf.cdo.session.CDOSession;
>
> import org.eclipse.emf.cdo.tests.AbstractCDOTest;
>
> import org.eclipse.emf.cdo.tests.model1.Category;
>
> import org.eclipse.emf.cdo.tests.model1.Company;
>
> import org.eclipse.emf.cdo.transaction.CDOTransaction;
>
> import org.eclipse.emf.cdo.transaction.CDOXATransaction;
>
> import org.eclipse.emf.cdo.util.CDOUtil;
>
> import org.eclipse.emf.cdo.view.CDOViewSet;
>
>
> public class TestDistributedTransactions extends AbstractCDOTest {
>
> public void testComparisonAcrossTransactions() throws Exception {
>
>
> Company company1 = getModel1Factory().createCompany();
>
> company1.setName("Your daddy");
>
>
> for (int i = 0; i < 10; i++) {
>
> Category category = getModel1Factory().createCategory();
>
> company1.getCategories().add(category);
>
> }
>
>
> CDOSession session = openModel1Session();
>
> CDOTransaction transaction = session.openTransaction();
>
>
> CDOViewSet viewSet1 = transaction.getViewSet();
>
> CDOXATransaction cdoxaTransaction = CDOUtil.createXATransaction();
>
> cdoxaTransaction.add(viewSet1);
>
>
> CDOResource res = transaction.getOrCreateResource("/res1");
>
> res.getContents().clear();
>
>
> transaction.commit();
>
> res.getContents().add(company1);
>
> transaction.commit();
>
>
> assertEquals(10, company1.getCategories().size());
>
>
> CDOSession session2 = openModel1Session();
>
> CDOTransaction transaction2 = session2.openTransaction();
>
>
> CDOViewSet viewSet2 = transaction2.getViewSet();
>
> cdoxaTransaction.add(viewSet2);
>
>
> CDOResource res2 = transaction2.getOrCreateResource("/res2");
>
>
> Category tempCategory = getModel1Factory().createCategory();
>
>
> company1.getCategories().add(tempCategory);
>
>
> res2.getContents().add(tempCategory);
>
>
> cdoxaTransaction.commit();
>
>
> System.out.println("Done");
>
> }
>
> }
>
>
>
Re: [CDO] Problem with CDOXATransaction [message #487503 is a reply to message #487479] Wed, 23 September 2009 13:13 Go to previous message
Eclipse UserFriend
Originally posted by: adomas.greicius.nomagic.com

I have filled bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=290251

"Adomas Greicius" <adomas.greicius@nomagic.com> wrote in message
news:h9d28h$d2s$1@build.eclipse.org...
> Hello Simon
>
> This is stack trace.
>
> Thread [main] (Suspended)
> Unsafe.park(boolean, long) line: not available [native method]
> LockSupport.parkNanos(long) line: 146
> FutureTask$Sync(AbstractQueuedSynchronizer).doAcquireSharedN anos(int,
> long)
> line: 912
> FutureTask$Sync(AbstractQueuedSynchronizer).tryAcquireShared Nanos(int,
> long) line: 1201
> FutureTask$Sync.innerGet(long) line: 210
> FutureTask<V>.get(long, TimeUnit) line: 85
> CDOXATransactionImpl.send(Collection<CDOXACommitContextImpl >,
> IProgressMonitor) line: 212
> CDOXATransactionImpl.commit(IProgressMonitor) line: 275
> CDOXATransactionImpl.commit() line: 253
> TestDistributedTransactions.testComparisonAcrossTransactions () line: 55
> NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not
> available [native method]
> NativeMethodAccessorImpl.invoke(Object, Object[]) line: 39
> DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 25
> Method.invoke(Object, Object...) line: 585
> TestDistributedTransactions(TestCase).runTest() line: 164
> TestDistributedTransactions(TestCase).runBare() line: 130
> TestDistributedTransactions(AbstractOMTest).runBare() line: 109
> TestResult$1.protect() line: 106
> TestResult.runProtected(Test, Protectable) line: 124
> TestResult.run(TestCase) line: 109
> TestDistributedTransactions(TestCase).run(TestResult) line: 120
> TestDistributedTransactions(AbstractOMTest).run(TestResult) line: 131
> TestSuite.runTest(Test, TestResult) line: 230
> TestSuite.run(TestResult) line: 225
> JUnit3TestReference.run(TestExecution) line: 130
> TestExecution.run(ITestReference[]) line: 38
> RemotePluginTestRunner(RemoteTestRunner).runTests(String[], String,
> TestExecution) line: 460
> RemotePluginTestRunner(RemoteTestRunner).runTests(TestExecut ion) line: 673
> RemotePluginTestRunner(RemoteTestRunner).run() line: 386
> RemotePluginTestRunner.main(String[]) line: 62
> CoreTestApplication.run(Object) line: 23
> NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not
> available [native method]
> NativeMethodAccessorImpl.invoke(Object, Object[]) line: 39
> DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 25
> Method.invoke(Object, Object...) line: 585
> EclipseAppContainer.callMethodWithException(Object, String, Class[],
> Object[]) line: 574
> EclipseAppHandle.run(Object) line: 195
> EclipseAppLauncher.runApplication(Object) line: 110
> EclipseAppLauncher.start(Object) line: 79
> EclipseStarter.run(Object) line: 386
> EclipseStarter.run(String[], Runnable) line: 179
> NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not
> available [native method]
> NativeMethodAccessorImpl.invoke(Object, Object[]) line: 39
> DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 25
> Method.invoke(Object, Object...) line: 585
> Main.invokeFramework(String[], URL[]) line: 549
> Main.basicRun(String[]) line: 504
> Main.run(String[]) line: 1236
> Main.main(String[]) line: 1212
>
>
> Other thread
>
> Thread [pool-3-thread-4] (Suspended)
> MEMStoreAccessor.write(IStoreAccessor$CommitContext, OMMonitor) line: 195
> XATransactionCommitContext(TransactionCommitContextImpl).wri te(OMMonitor)
> line: 269
> XATransactionCommitContext.write(OMMonitor) line: 69
> CommitManager$TransactionCommitContextEntry$1.call() line: 163
> FutureTask$Sync.innerRun() line: 269 [local variables unavailable]
> FutureTask<V>.run() line: 123
> ThreadPoolExecutor$Worker.runTask(Runnable) line: 650
> ThreadPoolExecutor$Worker.run() line: 675
> Thread.run() line: 595
>
> Can I help you with smth else? I think that this situaction should easy
> reproduse on you computers.
>
> "Adomas Greicius" <adomas.greicius@nomagic.com> wrote in message
> news:h9cj20$6gu$1@build.eclipse.org...
>> Hello,
>> I have wrote test. It has never ending commit on CDOXATransaction. I want
>> to ask is it right to use CDOXATransaction which has same resource loaded
>> in two transaction ?
>>
>> Adomas
>>
>>
>>
>> package com.nomagic.cdo.test.tests;
>>
>>
>> import org.eclipse.emf.cdo.eresource.CDOResource;
>>
>> import org.eclipse.emf.cdo.session.CDOSession;
>>
>> import org.eclipse.emf.cdo.tests.AbstractCDOTest;
>>
>> import org.eclipse.emf.cdo.tests.model1.Category;
>>
>> import org.eclipse.emf.cdo.tests.model1.Company;
>>
>> import org.eclipse.emf.cdo.transaction.CDOTransaction;
>>
>> import org.eclipse.emf.cdo.transaction.CDOXATransaction;
>>
>> import org.eclipse.emf.cdo.util.CDOUtil;
>>
>> import org.eclipse.emf.cdo.view.CDOViewSet;
>>
>>
>> public class TestDistributedTransactions extends AbstractCDOTest {
>>
>> public void testComparisonAcrossTransactions() throws Exception {
>>
>>
>> Company company1 = getModel1Factory().createCompany();
>>
>> company1.setName("Your daddy");
>>
>>
>> for (int i = 0; i < 10; i++) {
>>
>> Category category = getModel1Factory().createCategory();
>>
>> company1.getCategories().add(category);
>>
>> }
>>
>>
>> CDOSession session = openModel1Session();
>>
>> CDOTransaction transaction = session.openTransaction();
>>
>>
>> CDOViewSet viewSet1 = transaction.getViewSet();
>>
>> CDOXATransaction cdoxaTransaction = CDOUtil.createXATransaction();
>>
>> cdoxaTransaction.add(viewSet1);
>>
>>
>> CDOResource res = transaction.getOrCreateResource("/res1");
>>
>> res.getContents().clear();
>>
>>
>> transaction.commit();
>>
>> res.getContents().add(company1);
>>
>> transaction.commit();
>>
>>
>> assertEquals(10, company1.getCategories().size());
>>
>>
>> CDOSession session2 = openModel1Session();
>>
>> CDOTransaction transaction2 = session2.openTransaction();
>>
>>
>> CDOViewSet viewSet2 = transaction2.getViewSet();
>>
>> cdoxaTransaction.add(viewSet2);
>>
>>
>> CDOResource res2 = transaction2.getOrCreateResource("/res2");
>>
>>
>> Category tempCategory = getModel1Factory().createCategory();
>>
>>
>> company1.getCategories().add(tempCategory);
>>
>>
>> res2.getContents().add(tempCategory);
>>
>>
>> cdoxaTransaction.commit();
>>
>>
>> System.out.println("Done");
>>
>> }
>>
>> }
>>
>>
>>
>
>
Previous Topic:"Link" attribute in a model
Next Topic:howto?: emf databind to absent feature's value
Goto Forum:
  


Current Time: Thu Apr 18 04:14:41 GMT 2024

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

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

Back to the top