• 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:30:26 +0000
  • Thread-topic: locking with more coordinators causes an exception?

Hi,

On 2015-01-23, 3:20 PM, "OC" wrote:

Chuck,

On 24. 1. 2015, at 0:09, Chuck Hill <email@hidden> wrote:
Short answer: no, you should not be locking the object.  I’ve never seen anyone take out a database lock like this.

OK, I'll try, thanks!

===
        EOEditingContext ec=auction.editingContext()
        EOObjectStore osc=ec.rootObjectStore()
        osc.lock()
Why are you locking this?  Nothing in the code below needs it.

Learnt it here: http://terminalapp.net/dr-optimistic-locking/ -- have I misunderstood something of importance?

Ah, that Miguel, always worrying!  :-)  OK, I see what you are after.  IIRC, you can also handle this by catching notifications.  That discussion was a long time ago, I forget the particulars and don’t have time to re-read all of it now.

Chuck


       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

Anyway I'll try :)

            ... 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.

Thanks a lot,
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

References: 
 >locking with more coordinators causes an exception? (From: OC <email@hidden>)
 >Re: locking with more coordinators causes an exception? (From: Chuck Hill <email@hidden>)
 >Re: locking with more coordinators causes an exception? (From: OC <email@hidden>)

  • Prev by Date: Re: locking with more coordinators causes an exception?
  • Next by Date: Re: Wrong caching headers in browser
  • Previous by thread: Re: locking with more coordinators causes an exception?
  • Next by thread: "temporary invisible" object in database?!?
  • Index(es):
    • Date
    • Thread