AWADHAMBIKA(I)
arvind kushwaha wrote:Just synchronize the method which having database code. so that at a time one server only access that code.
Learning and Learning!-- Java all the way!
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
Learning and Learning!-- Java all the way!
AWADHAMBIKA(I)
AWADHAMBIKA(I)
Jacob Bogers wrote:Hi
,
Databases are build to handle concurrency from different "clients" (=any process/whatever that connects to the DB). Thats why Larry Ellison is so rich, he made a product thats very very good at this,
Why Databases "should" never lock on DML (especially select wich is not DML in reality but considered part of the commandset that does)
http://en.wikipedia.org/wiki/Isolation_%28computer_science%29
AWADHAMBIKA(I)
Binit Kumar wrote:By deadlock, here i mean is that, the SELECT query from both the JVMs try to get lock on the same rows in the DB
There is something called Phantom Read, which i am worried about
Binit Kumar wrote:
Jacob Bogers wrote:Hi
,
Databases are build to handle concurrency from different "clients" (=any process/whatever that connects to the DB). Thats why Larry Ellison is so rich, he made a product thats very very good at this,
Why Databases "should" never lock on DML (especially select wich is not DML in reality but considered part of the commandset that does)
http://en.wikipedia.org/wiki/Isolation_%28computer_science%29
Jacob,
There is something called Phantom Read, which i am worried about, as also mentioned in the Article link you shared. My SELECT queries are same for both the JVMs and they will fetch the same records as there is no WHERE condition in them. Kindly correct me if have misunderstood.
Tim Moores wrote:
Binit Kumar wrote:By deadlock, here i mean is that, the SELECT query from both the JVMs try to get lock on the same rows in the DB
Again: SELECTs do not cause anything to lock, so there can't be a deadlock.
There is something called Phantom Read, which i am worried about
Phantom reads can only occur if there are operations that alter data, not with SELECTs.
AWADHAMBIKA(I)
Jacob Bogers wrote:
Binit Kumar wrote:
Jacob Bogers wrote:Hi
,
Databases are build to handle concurrency from different "clients" (=any process/whatever that connects to the DB). Thats why Larry Ellison is so rich, he made a product thats very very good at this,
Why Databases "should" never lock on DML (especially select wich is not DML in reality but considered part of the commandset that does)
http://en.wikipedia.org/wiki/Isolation_%28computer_science%29
Jacob,
There is something called Phantom Read, which i am worried about, as also mentioned in the Article link you shared. My SELECT queries are same for both the JVMs and they will fetch the same records as there is no WHERE condition in them. Kindly correct me if have misunderstood.
If you are using Oracle (my speciality) then you can see which session is blocking wich or wich database objects are locked v$lock and v$access.. Numerous SQL scripts floating around on the internet that can query the database dictionary and show you this information,
You didnt tell us what DB you are using, we all here assume it is an entreprise level product. But lets say for argument sake you are right and one session on youe db is blocking another,..., then its pretty sure your code is doing something more then just a mere SELECT.
AWADHAMBIKA(I)
I am using ORACLE and my problem is more of the coding side rather than DB side. My session is not getting blocked, rather it is the competing situation that i have to ward off.
Binit Kumar wrote:
Today i thought of a solution, i will modify the query to get the data from DB for both servers i.e. one will get first X rownums and the other other next rownums i.e. i am trying for DB level solution.
Ireneusz Kordal wrote:
Binit Kumar wrote:
Today i thought of a solution, i will modify the query to get the data from DB for both servers i.e. one will get first X rownums and the other other next rownums i.e. i am trying for DB level solution.
Someone has just told you in this thread - simple queries that get the data do not cause deadlocks.
The problem is with order of your updates (or maybe with select with for update clause). Something like this:
Session 1: Update X
Session 2: Update Y
Session 1: Update Y --> session hangs and wait for changes of Y to be commited or rolled back in the other session
Session 2: Update X --> deadlock detected - one session must give up (while the second session is still waiting for commit or rollback in the other session)
Simple example (on Oracle 11):
Session 1
Session 2
Session 1Session 1 hangs and is waiting for release of the lock of id=3
Session 2Session 2 hangs and is waiting for release of the lock of id=1
Back to session 1:Session 2 is stopped, but Session 2 is still waiting for release of the lock of id=1
AWADHAMBIKA(I)
Politics n. Poly "many" + ticks "blood sucking insects". Tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
|