I don't quite know where to begin with this one.

I have a daemon process which has been dying unexpectedly and without any kind of warning. I think I've narrowed it down to an untie which doesn't return (or at the very least takes an abnormally long time to return).

Here are the open and close functions:
sub _open_db { my $self = shift; warn "_open_db $self $self->{NAME}\n"; # sorted index $DB_BTREE->{'flags'} = 0; $DB_BTREE->{'compare'} = sub { my ($key1, $key2) = @_; $key1 <=> $key2; }; if (tie(my %ip_db, 'DB_File', $self->{IP_FILE}, O_RDWR|O_CREAT, 0644, $DB_BTREE)) { # Enable duplicate keys as well $DB_BTREE->{'flags'} = R_DUP; if (my $stamp_tie = tie(my %stamp_db, 'DB_File', $self->{STAMP_FILE}, O_RDWR|O_CREAT, 0644, $DB_BTREE)) { $self->{IP_DB} = \%ip_db; $self->{STAMP_DB} = \%stamp_db; $self->{STAMP_TIE} = $stamp_tie; warn "_open_db OK IP_DB: $self->{IP_DB}" . " STAMP_DB: $self->{STAMP_DB} STAMP_TIE: $self->{STAMP_TIE}\n"; return $self; } else { $Err_Msg = "Can't open stamp db $self->{STAMP_FILE}: $!"; } warn "_open_db failed $Err_Msg\n"; untie %ip_db; warn "_open_db untie complete\n"; } else { $Err_Msg = "Can't open IP db $self->{IP_FILE}: $!" } warn "_open_db failed $Err_Msg\n"; return 0; } sub close_db { my $self = shift; warn "close_db $self\n"; delete $self->{STAMP_TIE}; warn "delete STAMP_TIE complete\n"; untie %{$self->{STAMP_DB}}; warn "untie STAMP_DB complete\n"; delete $self->{STAMP_DB}; warn "delete STAMP_DB complete\n"; untie %{$self->{IP_DB}}; warn "untie IP_DB complete\n"; delete $self->{IP_DB}; warn "delete IP_DB complete\n"; return 1; }
The databases are opened:
_open_db Db_file=HASH(0x838ad20) blacklist _open_db OK IP_DB: HASH(0x83f4960) STAMP_DB: HASH(0x83f429c) STAMP_T +IE: DB_File=SCALAR(0x83670f4) _open_db Db_file=HASH(0x83670e8) notify _open_db OK IP_DB: HASH(0x8367040) STAMP_DB: HASH(0x83658b8) STAMP_T +IE: DB_File=SCALAR(0x841651c) _open_db Db_file=HASH(0x83b4e84) notify_events _open_db OK IP_DB: HASH(0x838adbc) STAMP_DB: HASH(0x83b4e90) STAMP_T +IE: DB_File=SCALAR(0x841663c) _open_db Db_file=HASH(0x842e370) tracking _open_db OK IP_DB: HASH(0x84165dc) STAMP_DB: HASH(0x84165d0) STAMP_T +IE: DB_File=SCALAR(0x842f914) _open_db Db_file=HASH(0x80f53f0) tracking _open_db OK IP_DB: HASH(0x842f8b4) STAMP_DB: HASH(0x842e43c) STAMP_T +IE: DB_File=SCALAR(0x80f5540)
Then some time later, the databases are closed:
close_db Db_file=HASH(0x842e370) delete STAMP_TIE complete untie STAMP_DB complete delete STAMP_DB complete untie IP_DB complete delete IP_DB complete close_db Db_file=HASH(0x80f53f0) delete STAMP_TIE complete
One database is closed, but then the second database never returns from the first untie. The close/open cycle can repeat sucessfully for days on end, or it can zone out on the first try. Sometimes it stops on the first untie, sometimes the second. I haven't been able to reliably reproduce the error, but I've noticed I can 'encourage it' by causing more activity against the databases. The databases aren't unusually large, maybe 200k for the largest, most are less than 50k. I'm at a loss.

In reply to Problem with untie by ruzam

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.