Autoflush for DB_FILE to share a hash among cooperating processes?

Discussion in 'Perl Misc' started by Axel Boldt, Apr 7, 2004.

  1. Axel Boldt

    Axel Boldt Guest

    Hello,

    I want to share a hash variable among several forked processes.
    Ideally I would use threads and threads::shared, but I need LWP which
    is not thread-safe. So I thought about using DB_FILE and a hash
    variable tied to the same file in each of the processes. If one
    process changes the hash variable, all others should see the change
    immediately. I.e. I want that the change is immediately flushed to
    disk, and that every access to the hash variable takes its value
    directly from disk, not from some internal cache. Is that possible? I
    have tried the O_SYNC flag for db_open and also the $db->sync() method
    to no avail.

    If it's not possible, what do people usually do to keep a set of
    cooperating processes informed about the results that the other
    processes have already computed?

    Thanks,
    Axel
     
    Axel Boldt, Apr 7, 2004
    #1
    1. Advertisements

  2. Axel Boldt

    Dan Wilga Guest

    In article <>,
    (Axel Boldt) wrote:

    > Hello,
    >
    > I want to share a hash variable among several forked processes.
    > Ideally I would use threads and threads::shared, but I need LWP which
    > is not thread-safe. So I thought about using DB_FILE and a hash
    > variable tied to the same file in each of the processes. If one
    > process changes the hash variable, all others should see the change
    > immediately. I.e. I want that the change is immediately flushed to
    > disk, and that every access to the hash variable takes its value
    > directly from disk, not from some internal cache. Is that possible? I
    > have tried the O_SYNC flag for db_open and also the $db->sync() method
    > to no avail.


    I would recommend using the BerkeleyDB module instead of DB_File, and
    then using the DB_INIT_MPOOL and DB_INIT_CDB flags in a call to
    BerkeleyDB::Env.

    Anything less complex will lead to synchronization problems, since there
    is no record locking in Berkeley DB, unless you use either CDB or full
    transactional mode.

    --
    Dan Wilga
    ** Remove the -MUNGE in my address to reply **
     
    Dan Wilga, Apr 7, 2004
    #2
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Guadala Harry

    Share SQL DB Among Dozens of Sites

    Guadala Harry, Feb 21, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    416
    Peter Bromberg [C# MVP]
    Feb 21, 2004
  2. MK
    Replies:
    6
    Views:
    885
    noSpAm0000
    May 16, 2005
  3. red floyd
    Replies:
    1
    Views:
    577
    Zhang Yan
    Sep 6, 2003
  4. just_life
    Replies:
    0
    Views:
    781
    just_life
    Aug 1, 2007
  5. Nenad Prekupec

    how to share server control assembly among multiple programer enviroment?

    Nenad Prekupec, Nov 14, 2003, in forum: ASP .Net Building Controls
    Replies:
    1
    Views:
    208
    Nenad Prekupec
    Nov 14, 2003
  6. rp
    Replies:
    1
    Views:
    860
    red floyd
    Nov 10, 2011
  7. Saraswati lakki
    Replies:
    0
    Views:
    1,691
    Saraswati lakki
    Jan 6, 2012
  8. James

    DB_File (hash of array) problem

    James, Jun 22, 2010, in forum: Perl Misc
    Replies:
    5
    Views:
    277
    Xho Jingleheimerschmidt
    Jun 23, 2010
Loading...