• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: locking with more coordinators causes an exception?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: locking with more coordinators causes an exception?


  • Subject: Re: locking with more coordinators causes an exception?
  • From: Chuck Hill <email@hidden>
  • Date: Fri, 23 Jan 2015 23:09:42 +0000
  • Thread-topic: locking with more coordinators causes an exception?

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      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: locking with more coordinators causes an exception?
      • From: OC <email@hidden>
References: 
 >locking with more coordinators causes an exception? (From: OC <email@hidden>)

  • Prev by Date: Re: weird direct action behaviour -- am getting mangled URL sometimes
  • Next by Date: Re: "temporary invisible" object in database?!?
  • Previous by thread: locking with more coordinators causes an exception?
  • Next by thread: Re: locking with more coordinators causes an exception?
  • Index(es):
    • Date
    • Thread