This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of The Little Book of Impediments (e-book only) and have Tom Perry on-line!
See this thread for details.
Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

multiple inserts with multiple connections into same db table.

 
Scott William Sinclair
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Guys,

I hope someone can help
I have two or more threads which are inserting into the same target database table, each having their own connection. The connection has autoCommit set to false and I am performing batch inserts (batch size 10) and am only commiting once all inserts have been performed per thread.

My problem is that I am getting a deadlock, which I can't understand because I am only inserting into the one table.

I am using sybase 12.5.1

some output from sp_lock is below


Any help would be appreciated,

thanks.
 
Shailesh Chandra
Ranch Hand
Posts: 1082
Java Oracle Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
are all thread invoking same method for insert.

if yes then you can add synchonized keyword to you method.
[ October 28, 2004: Message edited by: Shailesh Chandra ]
 
Scott William Sinclair
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Thanks for the response, there is no common method for inserting.

I managed to change the server locking schema to "datarows" instead of "allpages", so it is row based instead of table based and that seems to have fixed it. I'm just confused how a deadlock could ocurr in the first place, since normally a deadlock requires two resources to be in contention.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic