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

Re: auto commit within JTS transaction  RSS feed

 
Alex Sharkoff
Ranch Hand
Posts: 209
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Tausif,

Cannot view your original messages



Pseudocode for <executeUpdateMethod>, which runs in container transaction2 as it has RequiresNew trans attribute


At the time when <callingMethod> called <SessionBean2#executeUpdateMethod> the container did not commit the results of [update <database_table_1>] operation into the database -> the database has X(exclusive) lock on the some part/all database_table_1. Because this method is run under "container transaction1" we can say that "container transaction1" has X(exclusive) lock on the some part/all database_table_1.

OK, now in <executeUpdateMethod> need to get S(shared) lock on some part/all database_table_1 in order to do [select from <database_table_1>]. Because running in "container transaction2" this method cannot get S(shared) lock till "container transaction1" releases X lock. However, "container transaction1" will not release this lock until method <SessionBean1#callingMethod> completes -> application hangs on <select> operation (application deadlock)

"Application deadlock" problem is something that you should have in mind when debugging your particular problem.

Does your <callingMethod> loop through <tableToUpdate> records and (for each record it finds) call <SessionBean2#executeUpdateMethod>? Try to make your <callingMethod> to only have a call to <SessionBean2#executeUpdateMethod>:



2. then I did a SELECT query on the same table which i want to update, WORKD FINE

Have you tried to loop through each record ( with ResultSet#next()) and lookup some record attribute ( with ResultSet#getXXX()?


Hope it helps ya a little.



[ August 18, 2004: Message edited by: Alex Sharkoff ]
[ August 18, 2004: Message edited by: Alex Sharkoff ]
 
Tausif Khanooni
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Alex,
Thnks for taking pain for me

the flow of my select and update goes like this:

1. Fetch all transaction to be updated:

sessionBean2#getTransactions, which inturns calls <getTransaction> method of
<DataAccessManagerSessionBean>
psedocode for <getTransaction> method of <DataAccessManagerSessionBean>


2. now i will loop thru this ArrayList and try to update the same table again with
updating other tables too

a. sessionBean2#updateTransaction(updateStmt), this method inturns calls
updateCommand(String updateStmt) method of <DataAccessManagerSessionBean>
b. sessionBean2#insertTransaction(insertStmt)

do u think i may have lock prob here?? if yes then why dont i get lock prob
while i m putting "TransNew" attrib for all methods in my ejb-jar.xml file??

Now Alex, i ask u one more prob which u must help me out... this is really serous
coz the first prob(above one) i may keep it working with setting "TransNew" attrib
for all methods in my ejb-jar.xml file, but if the one which i m listing below is
not solved, i m finished!!!

the prob is:

i m keeping my entry "RequiresNew" for all methods (say have <method-name>*</method-name> )
in ejb-jar.xml after updating few records successfully, i get this exception:



HELP ME DUDE!!
[ August 18, 2004: Message edited by: Tausif Khanooni ]
 
Tausif Khanooni
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hey alex m waiting for ur reply....
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!