I'm working on a script using DBI and DBD::CSV with Perl 5.6.0 on Solars. Every time it's run, I get flock() error messages that I can't explain, such as this one:

Execution ERROR: Cannot obtain exclusive lock on /u/jpfarmer/apps/shi +ftrpt/data/consultants: No record locks available at /u/jpfarmer/lib/ +site_perl/5.6.0/DBD/File.pm line 500. called from ./reporter at 30.

There is no way that another process is using the database (the program is only being run by me), and so I don't understand how the lock can be unavalible. I get similar error messages every time the Database is accessed. Also, if make a quick hack to to File.pm from DBD::CSV and force it to disable file locking, everything works fine.

I wrote a quick test script to try to apply a flock() to the database file, and it was successful, so the problem seems limited to my usage here. What could be going on?

sub build_consultant_data() { $dbh = DBI->connect("DBI:CSV:f_dir=$CSV_DATA") or die "Cannot connect: " . $DBI::errstr; # Connect to the DB my $directory = $ua->get('http://www.somwhere.com/blah/blah/blah/') ; # Get directory my $te = new HTML::TableExtract( headers => [qw/Name Int Username Group/] ) ; # Set up for TableExtract $te->parse( $directory->content ); # Extract the pertinent data my $ts = $te->first_table_state_found() ; # Create a table_state object to get at the rows $sth = $dbh->prepare( "INSERT INTO $CONSULTANT_TABLE VALUES (?, ?, ?, ?, ?)") or die "Cannot prepare: " . $dbh->errstr(); # Prepare to insert fields. my $i = 0; # Initalize counter foreach my $row ( $ts->rows ) { # Handle all the rows of data next unless @$row[0]; # Dump the row if the real name is empty my ( $ln, $fn ) = split ( /,/, @$row[0] ); # Extract last name $fn = ( split ( / /, $fn, 1 ) )[0]; # Remove middle name $sth->execute( $i++, $fn, $ln, @$row[2], @$row[3] ); } $dbh->disconnect(); # Disconnect from the DB }

In reply to Unexplained flock() errors by jpfarmer

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.