moshe wrote:
Quote:
my application is self deadlocked while trying to update data during a cursor
traversal. the cursor is holding a read lock on the resource which cause my
write operation to block. it is very common in my application to update data
according to traversed data, for example: iterating over the 'persons' table
and update some records in it according to some other recods. |
I think you have three choices:
1) use a transaction and perform all the operations 'in' that txn
2) perform all the operations using a single cursor,
3) use multiple cursors, but create all but the first using
DBC->c_dup() so that they all share the same locker id
These all have limitations of sorts.
Choice (1) may require major application changes, as transactions are
an all or nothing affair: you can only perform transactional updates on
tables that were opened inside a transaction and such tables cannot be
updated without using transactions (though DB_AUTO_COMMIT can hide the
txn in some cases).
Meanwhile, choices (2) and (3) may be impossible depending on the
operations involved. While most DB operations can be performed (or
emulated) using a cursor, there are several that can't. The obvious
ones are calls like DBENV->dbrename() and DB->truncate(), but it's also
true of DB->put(..., DB_APPEND). So, if your updates include those
sorts of operations, you'll have to use transactions.
Quote:
another thing,
in the documentation it is mentioned that the locks are held over "pages".
i dont understand what pages are. tables? records? |
Pages are a 'physical' level concept and are independent of records. A
file is typically treated as an ordered set of pages, all of the same
size. For example, if you're using pages of 8KB, then bytes 0 to 8191
are the first page, bytes 8192 to 16383 are the second page, etc. The
DB library stores records on pages, splitting them across pages in some
cases. How it does that is an internal detail of the DB library and
subject to change by Sleepycat between versions.
Quote:
where can i read about it? |
The references listed in the "Additional References" section of the DB
reference guide would be a good place to start.
Philip Guenther