
www.Usenet.com
| <-- __Chronological__ --> | <-- __Thread__ --> |
In fact, I don't think that it's safe to access a database and/or database environment unless the environment either uses the concurrent data store or transactional stuff. Note that there's a handy autocommit mode for transactions. It is reasonable to use multiple cursors on the same database, for instance to do a join. There's even a method for that. But like sarge says, don't leave them open, *especially* if they are update cursors. And when you update records, make sure you're always updating in the same order... this will minimize deadlocks. If you're exposing the database through an API, you may simply want to make it the API user's responsibility to follow this rule. I would also consider using Berkeley DB's deadlock scanner. This will prevent deadlocks from freezing up your whole process, and might help you locate code that frequently deadlocks. On Mon, 17 Nov 2003, Sarge wrote: > Cursors should never be "maintained." They should be created, > used, then immediately destroyed. I suggest you rewrite the > iterator interface to perform in this manner. You will be setting > yourself up for proper transaction usage as well. > > --Sarge > > "Erik Arner" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > > > > C'mon, isn't there anybody who can help me with this? > > > > Thanks > > Erik > > > > Erik Arner wrote: > > > > > > Hi, > > > > > > I have recently taken over development of an app which uses Berkley DB > > > for the underlying data storage (recno style, C++ API). The DB is hidden > > > behind an iterator interface that maintains a cursor into the DB > > > internally. Most of the data access through the iterator interface is > > > read-only, but in some cases data is written through the iterator. > > > > > > Problems arise when multiple iterators, and thereby multiple cursors, > > > are open at the same time. Under some (obscure) conditions, the app > > > deadlocks. As I understand it, this is a common problem when having > > > multiple handles into a DB at the same time. The app does not (not yet > > > anyway...) use transactions. > > > > > > My question: what would be the simplest, most hassle-free way for me to > > > enable having multiple cursors/handles open without going into deadlock? > > > As I'm a BDB newbie, I find the answer a bit hard to find out from the > > > docs and I'd appreciate any suggestions. > > > > > > Thanks, > > > Erik > > > > > > > >
| <-- __Chronological__ --> | <-- __Thread__ --> |