Skip to Main Content

Berkeley DB Family

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Unlocking a cursor

542197Jun 12 2007 — edited Jun 13 2007
I worked out a piece of code sometime ago with the help of Greybird, which basically looks up a record in a database, if it is there updates it, if not creates it. It works for multiple threads doing the same thing, locking the record with an RMW lock with the initial getSearchKey() cursor call.

Problem is, at the end of this routine it must release the lock, or you get horrendous deadlock problems. I used to do this by calling getNext(). Thing is, there was not always a next record (as you could be updating the last record). So now I do a getNext() if doing an update, followed by a getLast() if that failed. In the case of an insert, I do a getPrev() and if that fails, a getFirst(). It all seems a little random to me. Is there a better way of doing this (unlocking a cursor)? For example, it is shame you can't reposition on the current position, and lose the lock.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 11 2007
Added on Jun 12 2007
2 comments
1,228 views