|
Hi,
The sample code is like this: Class AController { def return = { if(session.key) { sleep(3000) // use the session.key do something remove(session.key) } } } But return method gets too many requests. So several threads are trying to get and delete session.key which causes race problem.
Is there any method could fix this problem? Thank you so much. Best, Gavin |
|
Why are you trying to synchronize on a session var? each visitor will have his own session, so, is this really necessary? []s, Lucas Teixeira On Wed, Jun 22, 2011 at 10:43 PM, Gavin Yue <[hidden email]> wrote: Hi, |
|
For example, user clicks the button twice pretty quickly.
In our case, it is a return call from paypal. Paypal quickly called method several times. On Wed, Jun 22, 2011 at 10:38 PM, Lucas F. A. Teixeira <[hidden email]> wrote:
|
|
You can use default grails utility to handle this:
http://grails.org/doc/latest/guide/single.html#6.1.11 Handling Duplicate Form Submissions
It works pretty well for us, and protect our app from these cases (frenetic users clicking around) []s, Lucas Teixeira On Wed, Jun 22, 2011 at 11:43 PM, Gavin Yue <[hidden email]> wrote: For example, user clicks the button twice pretty quickly. |
|
Thank you. But in our case, it is not form submission. It is just http get.
It is like you create two thread(request) and each of them try to read and modify one variable in the session.
On Wed, Jun 22, 2011 at 10:50 PM, Lucas F. A. Teixeira <[hidden email]> wrote: You can use default grails utility to handle this: |
|
Can't you work on some similar mechanism?
You can mark your session with a 'running' attribute, and remove it when paypal returns the response. Further requests would check the 'running' attirbute before making a new request.
[]s, Lucas Teixeira On Thu, Jun 23, 2011 at 12:12 AM, Gavin Yue <[hidden email]> wrote: Thank you. But in our case, it is not form submission. It is just http get. |
|
This is the sample code :
Class AController { def return = {
if(session.key) { sleep(5000) // use the session.key do something remove(session.key) } } } I removed the session.key variable. But another thread is too fast and the current thread sleeps for 5 seconds. On Wed, Jun 22, 2011 at 11:20 PM, Lucas F. A. Teixeira <[hidden email]> wrote: Can't you work on some similar mechanism? |
|
Doing a grails compile on an application that is configured with an inline plugin gives a unresolved dependency on that plugin.
This had worked fine with 1.3.7 but after upgrading it now produces this error. Anyone else encounter this? |
|
In reply to this post by xmly
Do what most merchants do, disable the button and tell them not to refresh the page. From: Gavin Yue <[hidden email]> Reply-To: <[hidden email]> Date: Wed, 22 Jun 2011 22:43:19 -0400 To: <[hidden email]> Subject: Re: [grails-user] Any way to synchronize on session variables In our case, it is a return call from paypal. Paypal quickly called method several times. On Wed, Jun 22, 2011 at 10:38 PM, Lucas F. A. Teixeira <[hidden email]> wrote:
|
|
What about something along the lines: if ( !session.paymentInProgress ) { session.paymentInProgress = true
// Do something session..paymentInProgress = false } else { ... } / Mohamed
On Thu, Jun 23, 2011 at 9:28 AM, Adrian Roston <[hidden email]> wrote:
|
|
I thought this method as well. But in the very extreme cases, what if two threads are both trying to set: session.paymentInProgress = true ? Because they both check session.paymentInProgress at the same time and find it is null.
On Thu, Jun 23, 2011 at 7:15 AM, Mohamed Seifeddine <[hidden email]> wrote:
|
|
Maybe extreme approach: How about putting a session-specific token in the DB and doing a pessimistic lock on it?
Jason
On Thu, Jun 23, 2011 at 10:08 AM, Gavin Yue <[hidden email]> wrote: I thought this method as well. But in the very extreme cases, what if two threads are both trying to set: session.paymentInProgress = true ? Because they both check session.paymentInProgress at the same time and find it is null. |
|
Administrator
|
In reply to this post by sd
Please raise a JIRA with an example
Cheers On Thu, Jun 23, 2011 at 7:53 AM, <[hidden email]> wrote: > Doing a grails compile on an application that is configured with an inline > plugin gives a unresolved dependency on that plugin. > > This had worked fine with 1.3.7 but after upgrading it now produces this > error. > > Anyone else encounter this? > -- Graeme Rocher Grails Project Lead SpringSource - A Division of VMware http://www.springsource.com --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
| Powered by Nabble | Edit this page |
