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:

  1. Obtain SharedNFSLock.
  2. Do work.
  3. Force DB sync. (to clear out dirty pages in the cache)
  4. 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.

Thanks.

--DrWhy

"If God had meant for us to think for ourselves he would have given us brains. Oh, wait..."


In reply to [OT]? Behavior of Berkeley DB cache when reading cached page that was changed on disk by another app by DrWhy

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • 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:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, 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, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.