Skip Menu |

This queue is for tickets about the Search-InvertedIndex CPAN distribution.

Report information
The Basics
Id: 20963
Status: open
Priority: 0/
Queue: Search-InvertedIndex

People
Owner: Nobody in particular
Requestors: alexchorny [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: Critical
Broken in: 1.14
Fixed in: (no value)



Subject: DB_File locking scheme fails on Windows
Search::InvertedIndex tests fail on Microsoft Windows, because of locking scheme in DB_File_SplitHash.pm in sub _open_multi_map. my $fd = $db_object->fd; $fd is equal to -1. Also this scheme is not recomended by DB_File: http://search.cpan.org/~pmqs/DB_File-1.814/DB_File.pm#Locking%3A_The_Trouble_with_fd because of race condition. There are two possible solutions: 1. Switch to BerkeleyDB perl module which uses BerkeleyDB 2 locking possibilities. 2. Use additional lock file (modules are described in DB_File pod). ------- Alexandr Ciornii, http://chorny.net
From: barborak [...] basikgroup.com
If anyone needs a workaround, open the DB_File_SplitHash.pm file and find this code: my $fh = "FH_COUNTER_$FH_COUNT"; no strict 'refs'; CORE::open ($fh, "+<&=$fd") or croak (__PACKAGE__ . "::_open_multi_map() - unable to open file descriptor for locking: $!"); local ( *LOCKFH ); use strict 'refs'; $self->SUPER::set({ -filehandle => $fh, -lock_mode => 'UN', -hash => $hash, -fd => $fd, }); Replace it with this: my $fh = "FH_COUNTER_$FH_COUNT"; no strict 'refs'; local ( *LOCKFH ); CORE::open (LOCKFH, "> $map/lockFile") or croak (__PACKAGE__ . "::_open_multi_map() - unable to open file descriptor for locking: $!"); use strict 'refs'; $self->SUPER::set({ -filehandle => *LOCKFH, -lock_mode => 'UN', -hash => $hash, -fd => $fd, }); Note that this only works with multi-maps (-multi set greater than 1). That's because what this hack does is create a file in the map's folder (named lockFile) to do the actual locking on. Only when multi is greater than one is the map a folder. Good luck, Mike