Okay so this is really a Berkeley DB question, but it's for a Perl application so I'm posting it here to see if anyone can help out.
I'm using Berkeley DB in an manner that is not approved of by the great Berkeley DB oracles-that-be. I'm using it from a shared disk in a distributed environment with multiple processes on mulitple machines reading and writing simultaneously. The saving grace, if there is one here is that there is expected to be very infrequent, but still possible cases of two processes on different machines accessing the BDB at the same time.
Going off a tip from the Oracle Berkeley DB FAQ online, I'm taking the following approach: Do external locking on the entire DB, handled by the application. I'm planning to use File::SharedNFSLock for this purpose.
I could just get a lock at the beginning of each app's run and that would be sufficient to get the locking I need, completely serializing access to the DB at a very high level. This would waste alot of time so I was looking at having each app take and release a lock several times around logical units of DB work within the app. Each unit of activity would look like:
- Obtain SharedNFSLock.
- Do work.
- Force DB sync. (to clear out dirty pages in the cache)
- Release SharedNFSLock.
What I'm not doing here is closing and reopening the DB inside each unit of work -- the DB handle is opened at the beginning of each Perl script and closed only at the end. If I do this though I wonder what's going to happen about cached pages. Will they be able to detect when a page has been modified by another process on another computer and reget that page when an operation is called involving that page? If not, then processes will miss getting updates made by other processes while they are running. I haven't been able to find anywhere on the web a description of how the caching works in Berkeley DB (and I don't feel like reading that Berekeley DB source to figure it out for myself, since that seems like it could take me quite along time to get to the information I need).
So I'm wondering if anyone here knows enough about the internals of the BDB cache to be able to help out here.
"If God had meant for us to think for ourselves he would have given us brains. Oh, wait..."
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
Outside of code tags, you may need to use entities for some characters:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.
| & || & |
| < || < |
| > || > |
| [ || [ |
| ] || ] ||