concurrent locking strategy

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

concurrent locking strategy

Paul Blakeley
Hi,
  I am currently working on a project that has multiple users that can modify store items.  I would like to code a solution that would lock an item from being modified once another user starts to modify its contents.  I would to highlight this through some rendered html on the store item list page. I wondered if someone has had previously experienced doing this kind of thing and possibly sharing their solution with me? 

--
You received this message because you are subscribed to the Google Groups "Grails Dev Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/grails-dev-discuss/9941db42-921e-40ff-92b5-c1904a5e823f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: concurrent locking strategy

Gregory Dickson
You should review the Grails/GORM docs on versioning and optimistic locking: http://docs.grails.org/3.1.10/guide/GORM.html#optimisticLockingAndVersioning

One time I wanted to absolutely lock a row for an indefinite period of time. So, I created a field called 'status' on the domain object and then I would do a manual .lock() (see GORM documentation) on the object, update the field to 'locked', .save() the domain object, then when the user could 'own' it for an indefinite amount of time, and when they finished with that object, they would update it to another status.

I would recommend reading all the Grails and GORM documentation on locking, pessimistic/optimistic and especially, object versioning. Also, you can try the Grails Slack channel as you might find other input.

On Monday, October 17, 2016 at 2:14:48 PM UTC-5, Paul Blakeley wrote:
Hi,
  I am currently working on a project that has multiple users that can modify store items.  I would like to code a solution that would lock an item from being modified once another user starts to modify its contents.  I would to highlight this through some rendered html on the store item list page. I wondered if someone has had previously experienced doing this kind of thing and possibly sharing their solution with me? 

--
You received this message because you are subscribed to the Google Groups "Grails Dev Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/grails-dev-discuss/cb4fed42-5710-4abc-b16b-0d9f74b69727%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: concurrent locking strategy

Paul Blakeley
Thank you for your comprehensive answer.  That helps.  I have read about the optimistic and pessimistic locking.  With respect to the .lock method(pessimistic locking) I was under the impression that the lock would effectively be unlocked on the completion of the transaction??? Which is not really desirable for me. 

On Tuesday, 18 October 2016 18:06:56 UTC+1, Gregory Dickson wrote:
You should review the Grails/GORM docs on versioning and optimistic locking: <a href="http://docs.grails.org/3.1.10/guide/GORM.html#optimisticLockingAndVersioning" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fdocs.grails.org%2F3.1.10%2Fguide%2FGORM.html%23optimisticLockingAndVersioning\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFMCxPeI8j__zoJBdS2GJ6BsYgFEA&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fdocs.grails.org%2F3.1.10%2Fguide%2FGORM.html%23optimisticLockingAndVersioning\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFMCxPeI8j__zoJBdS2GJ6BsYgFEA&#39;;return true;">http://docs.grails.org/3.1.10/guide/GORM.html#optimisticLockingAndVersioning

One time I wanted to absolutely lock a row for an indefinite period of time. So, I created a field called 'status' on the domain object and then I would do a manual .lock() (see GORM documentation) on the object, update the field to 'locked', .save() the domain object, then when the user could 'own' it for an indefinite amount of time, and when they finished with that object, they would update it to another status.

I would recommend reading all the Grails and GORM documentation on locking, pessimistic/optimistic and especially, object versioning. Also, you can try the Grails Slack channel as you might find other input.

On Monday, October 17, 2016 at 2:14:48 PM UTC-5, Paul Blakeley wrote:
Hi,
  I am currently working on a project that has multiple users that can modify store items.  I would like to code a solution that would lock an item from being modified once another user starts to modify its contents.  I would to highlight this through some rendered html on the store item list page. I wondered if someone has had previously experienced doing this kind of thing and possibly sharing their solution with me? 

--
You received this message because you are subscribed to the Google Groups "Grails Dev Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/grails-dev-discuss/e65f4f97-284f-4912-a567-a69d5c5ab520%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: concurrent locking strategy

Gregory Dickson
yes, .lock() is only scoped to the request/response scope.



On Tue, Oct 18, 2016 3:15 PM, Paul Blakeley [hidden email] wrote:
Thank you for your comprehensive answer.  That helps.  I have read about the optimistic and pessimistic locking.  With respect to the .lock method(pessimistic locking) I was under the impression that the lock would effectively be unlocked on the completion of the transaction??? Which is not really desirable for me. 

On Tuesday, 18 October 2016 18:06:56 UTC+1, Gregory Dickson wrote:
You should review the Grails/GORM docs on versioning and optimistic locking: <a href="http://docs.grails.org/3.1.10/guide/GORM.html#optimisticLockingAndVersioning" target="_blank" rel="nofollow" onmousedown="this.href='http://www.google.com/url?q\x3dhttp%3A%2F%2Fdocs.grails.org%2F3.1.10%2Fguide%2FGORM.html%23optimisticLockingAndVersioning\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFMCxPeI8j__zoJBdS2GJ6BsYgFEA';return true;" onclick="this.href='http://www.google.com/url?q\x3dhttp%3A%2F%2Fdocs.grails.org%2F3.1.10%2Fguide%2FGORM.html%23optimisticLockingAndVersioning\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFMCxPeI8j__zoJBdS2GJ6BsYgFEA';return true;">http://docs.grails.org/3.1.10/guide/GORM.html#optimisticLockingAndVersioning

One time I wanted to absolutely lock a row for an indefinite period of time. So, I created a field called 'status' on the domain object and then I would do a manual .lock() (see GORM documentation) on the object, update the field to 'locked', .save() the domain object, then when the user could 'own' it for an indefinite amount of time, and when they finished with that object, they would update it to another status.

I would recommend reading all the Grails and GORM documentation on locking, pessimistic/optimistic and especially, object versioning. Also, you can try the Grails Slack channel as you might find other input.

On Monday, October 17, 2016 at 2:14:48 PM UTC-5, Paul Blakeley wrote:
Hi,
  I am currently working on a project that has multiple users that can modify store items.  I would like to code a solution that would lock an item from being modified once another user starts to modify its contents.  I would to highlight this through some rendered html on the store item list page. I wondered if someone has had previously experienced doing this kind of thing and possibly sharing their solution with me? 

--
You received this message because you are subscribed to the Google Groups "Grails Dev Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/grails-dev-discuss/e65f4f97-284f-4912-a567-a69d5c5ab520%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Grails Dev Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/grails-dev-discuss/9393d6cb-2714-fb22-5216-a47b2da79af7%40mixmax.com.
For more options, visit https://groups.google.com/d/optout.
Loading...