Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [CDO] Concurrent accesses and ObjectNotFoundException
[CDO] Concurrent accesses and ObjectNotFoundException [message #1699056] Fri, 19 June 2015 22:02 Go to next message
Stephane  fournier is currently offline Stephane fournierFriend
Messages: 340
Registered: July 2009
Senior Member
Hi there,

I'am facing an issue and I would like some suggestions to manage it correctly Smile

Let suppose you have 2 CDO clients (A & B) running in separate JVM connected to a CDO server (Mem Store) in a 3rd JVM.

The metamodel is the following one :

- Company
contains Employees.
- Employee has:
- a name attribute (EString) ,
- lastUpdateDate containment relationship (MyDate)
-MyDate
- time attribute (ELong)

Client A adds / removes employees in one Company instance "FooBarCompany" and is also be able to set a new MyDate instance on Employee instances let's say to date lastModification on it (dummy reason just for the use case).

Client B runs a repeatable TimerTask each second:
In this task, it does this :

for (Employee current : company.getEmployees) {
current.getLastUpdateDate().getTime()
....
}

But sometimes I got CDO ObjectNotFoundException on the call on getTime().
Indeed, the object is changed in // by client A (the other client JVM) whereas client B is looping and trying to access the lastUpdateDate relationship which is removed on server side hence the object is not valid I guess because the client B transaction is not updated yet against the server ?

I would really appreciate any suggestions to manage this kind of scenario properly.

Should I only catch the exception and try to get the instance again ?

What happens during the loop done by client B, if client A removes an Employee ?
I suppose I will get the same CDO ObjectNotFound exception ?

What is the right solution to manage this please ?

Stéphane.
Re: [CDO] Concurrent accesses and ObjectNotFoundException [message #1699065 is a reply to message #1699056] Sat, 20 June 2015 05:27 Go to previous messageGo to next message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6682
Registered: July 2009
Senior Member
Hi Stephane,

Your client B may want to use a (read) lock to ensure that the object under access is not deleted by other clients.

Cheers
/Eike

----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper



Am 20.06.2015 um 00:02 schrieb Stephane Fournier:
> Hi there,
>
> I'am facing an issue and I would like some suggestions to manage it correctly :)
>
> Let suppose you have 2 CDO clients (A & B) running in separate JVM connected to a CDO server (Mem Store) in a 3rd JVM.
>
> The metamodel is the following one :
>
> - Company contains Employees.
> - Employee has:
> - a name attribute (EString) , - lastUpdateDate containment relationship (MyDate)
> -MyDate - time attribute (ELong)
>
> Client A adds / removes employees in one Company instance "FooBarCompany" and is also be able to set a new MyDate
> instance on Employee instances let's say to date lastModification on it (dummy reason just for the use case).
>
> Client B runs a repeatable TimerTask each second: In this task, it does this :
>
> for (Employee current : company.getEmployees) {
> current.getLastUpdateDate().getTime()
> ....
> }
>
> But sometimes I got CDO ObjectNotFoundException on the call on getTime().
> Indeed, the object is changed in // by client A (the other client JVM) whereas client B is looping and trying to
> access the lastUpdateDate relationship which is removed on server side hence the object is not valid I guess because
> the client B transaction is not updated yet against the server ?
>
> I would really appreciate any suggestions to manage this kind of scenario properly.
>
> Should I only catch the exception and try to get the instance again ?
>
> What happens during the loop done by client B, if client A removes an Employee ? I suppose I will get the same CDO
> ObjectNotFound exception ?
>
> What is the right solution to manage this please ?
>
> Stéphane.
>


Re: [CDO] Concurrent accesses and ObjectNotFoundException [message #1699068 is a reply to message #1699065] Sat, 20 June 2015 08:01 Go to previous messageGo to next message
Stephane  fournier is currently offline Stephane fournierFriend
Messages: 340
Registered: July 2009
Senior Member
Hi Eike,

thanks again for your quick answer.

I have already experiences how to lock objects with CDOAutoLocker handler but I don't know how to do quite the same thing at read time without explicitly doing :

CDOLock cdoReadLock = company.cdoReadLock();
cdoReadLock.lock(timeout);

....
...
cdoReadLock.unlock();

everywhere in the application code.

By the way, if client A (JVM 1) uses CDOAutoLocker whereas client B (JVM 2) holds a ReadLock, client A trying to modify the same objects, will be blocked in the CDOAutoLocker until the client B has released its READ Lock ?
What happens if the client B JVM crashes ? the read lock is stil there ?

Stéphane.
Re: [CDO] Concurrent accesses and ObjectNotFoundException [message #1699077 is a reply to message #1699068] Sat, 20 June 2015 12:18 Go to previous messageGo to next message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6682
Registered: July 2009
Senior Member
Am 20.06.2015 um 10:01 schrieb Stephane Fournier:
> Hi Eike,
>
> thanks again for your quick answer.
>
> I have already experiences how to lock objects with CDOAutoLocker handler but I don't know how to do quite the same
> thing at read time without explicitly doing :
>
> CDOLock cdoReadLock = company.cdoReadLock();
> cdoReadLock.lock(timeout);
>
> ...
> ..
> cdoReadLock.unlock();
>
> everywhere in the application code.
Locking is a pretty heavy mechanism in terms of signaling, too. Maybe you're better of by expecting respective
exceptions and handling them more gracefully, e.g. do the read again.

>
> By the way, if client A (JVM 1) uses CDOAutoLocker whereas client B (JVM 2) holds a ReadLock, client A trying to
> modify the same objects, will be blocked in the CDOAutoLocker until the client B has released its READ Lock ?
Yes.

> What happens if the client B JVM crashes ? the read lock is stil there ?
No, all locks are owned by the locking view/transaction and are released when that view/transaction is closed (for
whatever reason).

Please note that especially in this area I fixed some bugs for CDO 4.4.

Cheers
/Eike

----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper


Re: [CDO] Concurrent accesses and ObjectNotFoundException [message #1699541 is a reply to message #1699077] Wed, 24 June 2015 22:13 Go to previous messageGo to next message
Stephane  fournier is currently offline Stephane fournierFriend
Messages: 340
Registered: July 2009
Senior Member
Hi Eike,
Thanks for your explanations.

I've just discovered the serializeCommits settings on server side.
To work with CDOMergingConflictREsolver, is it recommended to set it to true on server side with a mem store bad server ?

Thanks,
Stephane.

Eike Stepper wrote on Sat, 20 June 2015 08:18
Am 20.06.2015 um 10:01 schrieb Stephane Fournier:
> Hi Eike,
>
> thanks again for your quick answer.
>
> I have already experiences how to lock objects with CDOAutoLocker handler but I don't know how to do quite the same
> thing at read time without explicitly doing :
>
> CDOLock cdoReadLock = company.cdoReadLock();
> cdoReadLock.lock(timeout);
>
> ...
> ..
> cdoReadLock.unlock();
>
> everywhere in the application code.
Locking is a pretty heavy mechanism in terms of signaling, too. Maybe you're better of by expecting respective
exceptions and handling them more gracefully, e.g. do the read again.

>
> By the way, if client A (JVM 1) uses CDOAutoLocker whereas client B (JVM 2) holds a ReadLock, client A trying to
> modify the same objects, will be blocked in the CDOAutoLocker until the client B has released its READ Lock ?
Yes.

> What happens if the client B JVM crashes ? the read lock is stil there ?
No, all locks are owned by the locking view/transaction and are released when that view/transaction is closed (for
whatever reason).

Please note that especially in this area I fixed some bugs for CDO 4.4.

Cheers
/Eike

----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper
Re: [CDO] Concurrent accesses and ObjectNotFoundException [message #1700084 is a reply to message #1699541] Tue, 30 June 2015 05:10 Go to previous messageGo to next message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6682
Registered: July 2009
Senior Member
Am 25.06.2015 um 00:13 schrieb Stephane Fournier:
> Hi Eike,
> Thanks for your explanations.
>
> I've just discovered the serializeCommits settings on server side.
> To work with CDOMergingConflictREsolver, is it recommended to set it to true on server side
I don't think that's related.

> with a mem store bad server ?
What is a bad server?

Cheers
/Eike

----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper


Re: [CDO] Concurrent accesses and ObjectNotFoundException [message #1700213 is a reply to message #1700084] Tue, 30 June 2015 20:08 Go to previous messageGo to next message
Stephane  fournier is currently offline Stephane fournierFriend
Messages: 340
Registered: July 2009
Senior Member
Hi Eike,
bad is the result of the auto-correction on OS X Smile

if the serializeCommits is enabled, I understand the commit operations are put in a FIFO queue to process them one after one.
If the serializeCommits is disabled, how the commit operations are processed ?

Thanks,
Stéphane.

Eike Stepper wrote on Tue, 30 June 2015 01:10
Am 25.06.2015 um 00:13 schrieb Stephane Fournier:
> Hi Eike,
> Thanks for your explanations.
>
> I've just discovered the serializeCommits settings on server side.
> To work with CDOMergingConflictREsolver, is it recommended to set it to true on server side
I don't think that's related.

> with a mem store bad server ?
What is a bad server?

Cheers
/Eike

----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper

Re: [CDO] Concurrent accesses and ObjectNotFoundException [message #1701696 is a reply to message #1700213] Wed, 15 July 2015 05:57 Go to previous message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6682
Registered: July 2009
Senior Member
Am 30.06.2015 um 22:08 schrieb Stephane Fournier:
> Hi Eike,
> bad is the result of the auto-correction on OS X :)
>
> if the serializeCommits is enabled, I understand the commit operations are put in a FIFO queue to process them one
> after one.
Yes.

> If the serializeCommits is disabled, how the commit operations are processed ?
Concurrently with locks on the changed objects (and some more objects, depending on referential integrity needs).

Cheers
/Eike

----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper


>
> Thanks,
> Stéphane.
>
> Eike Stepper wrote on Tue, 30 June 2015 01:10
>> Am 25.06.2015 um 00:13 schrieb Stephane Fournier:
>> > Hi Eike,
>> > Thanks for your explanations.
>> >
>> > I've just discovered the serializeCommits settings on server side.
>> > To work with CDOMergingConflictREsolver, is it recommended to set it to true on server side I don't think that's
>> related.
>>
>> > with a mem store bad server ?
>> What is a bad server?
>>
>> Cheers
>> /Eike
>>
>> ----
>> http://www.esc-net.de
>> http://thegordian.blogspot.com
>> http://twitter.com/eikestepper
>
>


Previous Topic:[CDO] Authenticate against a LDAP server
Next Topic:emf json problem
Goto Forum:
  


Current Time: Thu Mar 28 16:39:19 GMT 2024

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

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

Back to the top