Short answer: no, you should not be locking the object.  I've never seen anyone 
take out a database lock like this.

More below.

On 2015-01-23, 6:32 AM, "OC" wrote:

Hello there,

in the same new log, I've bumped into another problem. My application uses

WOAllowsConcurrentRequestHandling = true
er.extensions.ERXObjectStoreCoordinatorPool.maxCoordinators=3

My saving code looks like this:

===
        EOEditingContext ec=auction.editingContext()
        EOObjectStore osc=ec.rootObjectStore()
        osc.lock()

Why are you locking this?  Nothing in the code below needs it.


        try {
            EOEditingContext tempec=ERXEC.newEditingContext()
            tempec.fetchTimestamp=System.currentTimeMillis()
            def tempau=auction.localInstanceIn(tempec)
            tempec.lockObject(tempau) // *

Don't do this.  It is not needed.  Well, for most people.  With you I am not so 
sure...  :-P



            ... yadda yadda yadda ...

            tempec.saveChanges();
       } catch (exc) {
            PRINT_ERROR(exc,"Exception adding price offer FOR prc $poValue CU 
$sess.currentUser.login")
            ...
        } finally {
            osc.unlock()
        }
===

Is the // * lock wrong? I've thought if two threads try to work with the same 
auction, the latter one would wait in the lock until the former saves.

The normal way to handle this is just to save and detail with any optimistic 
locking conflicts that happen.


Looks like I was wrong: two users tried to save concurrently; they both locked 
their OSC's all right, but then I've got an exception

===
Caused by: java.lang.IllegalStateException: Failed to lock 
object:com.webobjects.eoaccess.EODatabaseContext@15e1e22b with 
gid:_EOIntegralKeyGlobalID[DBAuction (java.lang.Integer)1000409]
at 
com.webobjects.eoaccess.EODatabaseContext.lockObjectWithGlobalID(EODatabaseContext.java:3287)
at 
com.webobjects.eocontrol.EOObjectStoreCoordinator.lockObjectWithGlobalID(EOObjectStoreCoordinator.java:525)
at 
com.webobjects.eocontrol.EOEditingContext.lockObjectWithGlobalID(EOEditingContext.java:4237)
at 
com.webobjects.eocontrol.EOEditingContext.lockObject(EOEditingContext.java:4461)
at er.extensions.eof.ERXEC.lockObject(ERXEC.java:1376)
at er.extensions.eof.ERXEC$lockObject$9.call(Unknown Source)
at components.sharedparts.BidsEditor$_addPriceOffer(BidsEditor.groovy:411) // 
this is the lockObject(tempau) // *
===

What am I doing wrong? Should I _not_ lock the objects I am working with when 
saving?

Thanks,
OC


_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      
(Webobjects-dev@lists.apple.com<mailto:Webobjects-dev@lists.apple.com>)
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/webobjects-dev/chill%40gevityinc.com

This email sent to ch...@gevityinc.com<mailto:ch...@gevityinc.com>
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to