dbTalk Databases Forums  

lock conflicts, even when using transactions

comp.databases.berkeley-db comp.databases.berkeley-db


Discuss lock conflicts, even when using transactions in the comp.databases.berkeley-db forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Petra Chong
 
Posts: n/a

Default lock conflicts, even when using transactions - 10-25-2006 , 08:19 AM






I'm quite a newbie when it comes to using Berkeley DB. I am using BDB
dbxml.

I have an application that fetches data from an external source and
writes that into dbxml. The data fetch takes a long time, so I start a
new thread to do this. All writes into dbxml for that batch are then
done in that same new thread.

When I have a few batches running at the same time, after variable
amounts of time, the application will hang. When this happens my only
option is to run db_recover.

The problem happens when I have more than one of these: multiple writes
in multiple threads. I am protecting everything with transactions, but
am getting lock conflicts.

The output of db_stat -CA includes this:

1 Total number of locks not immediately available due to
conflicts

80000275 READ 28 HELD RefData page
3105
80000275 WRITE 55 HELD RefData page
3105
80000276 READ 1 WAIT RefData page
3105

Unfortunately, I don't know how to interpret this. How do I tell where
the conflict is happening? What sort of pattern should I be following
to prevent this from happening?

Many thanks,

PC


Reply With Quote
  #2  
Old   
Florian Weimer
 
Posts: n/a

Default Re: lock conflicts, even when using transactions - 10-25-2006 , 12:49 PM






* Petra Chong:

Quote:
The problem happens when I have more than one of these: multiple writes
in multiple threads. I am protecting everything with transactions, but
am getting lock conflicts.
Do you run any kind of deadlock detector?


Reply With Quote
  #3  
Old   
Petra Chong
 
Posts: n/a

Default Re: lock conflicts, even when using transactions - 10-26-2006 , 05:49 AM




Florian Weimer wrote:
Quote:
* Petra Chong:

The problem happens when I have more than one of these: multiple writes
in multiple threads. I am protecting everything with transactions, but
am getting lock conflicts.

Do you run any kind of deadlock detector?
I do- but it didn't help.

However, I have solved the problem like this:

(I am using dbxml)

1. All queries use XmlQueryContext.DeadValues except where live values
are truly necessary. This reduced the read-write lock conflicts
considerably

2. All queries specify DB_RMW if they are selecting nodes to be
modified later (read-modify-write pattern)

This got me to the point where I was getting write-write lock
conflicts. This was easy to solve by:

3. Making all writes in my application single-threaded. I realise that
this solution is probably not acceptable for other applications, but my
usage pattern is such that single-threaded writes are acceptable.
Basically I am running a series of batch uploads where the source data
comes from an external source that takes a long time to return. The
data is only useful to me after it has completed uploading; it doesn't
matter whether 5 batches run sequentially or are interleaved- I only
care about when they are all uploaded completely.

Regards

PC



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.