Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to synch in cluster?  RSS feed

 
avihai marchiano
Ranch Hand
Posts: 342
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey,

I have two process that cannot run in parallel.
How can i check if process A run than dont run process B.

I think on have a flag in the DB, but this is required ugly code that lock for update save running flag...
And you need to try and catch (i dont love coding by exception) to see if you get exception for locking.

Any ideas?

Thank you
 
Angel Taveras
Ranch Hand
Posts: 84
Eclipse IDE Hibernate Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can lock the specific records on the database so every other process that hits the same record for update it will wait
until the lock it's released. Those processes that don't update the record but read data from them will read the data consistently.
For this to work your database must support row locking.


 
avihai marchiano
Ranch Hand
Posts: 342
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
this is the solution i think to do.
sync with share record in db and update when running.

the thing that i dont love it is that you need to "coding by exception". means - the process will need to do select for update and wait for exception to know if it can run.
 
Angel Taveras
Ranch Hand
Posts: 84
Eclipse IDE Hibernate Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes but you can wait for a timeout and retry again. Most of the Async IO and stuff with threading have to do
something similar to yield the proc to other processes. This does not means that you have to do that but it's an approach
 
Ajay Saxena
Ranch Hand
Posts: 154
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try the "select for update nowait" semantic available on some DBMSes. Also, there's probably a way to configure a timeout on the plain "select fro update" clause.
 
Onkar Joshi
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Consider exploring a bit to see if Terracotta will fit into your needs.
 
Onkar Joshi
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Perhaps this would help? : Using Quartz scheduler in a cluster
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!