Skip Menu |

This queue is for tickets about the DBIx-Class CPAN distribution.

Report information
The Basics
Id: 78420
Status: resolved
Priority: 0/
Queue: DBIx-Class

People
Owner: Nobody in particular
Requestors: d.thomas [...] its.uq.edu.au
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in:
  • 0.08198
  • 0.08200
Fixed in: 0.08203



Subject: t/storage/reconnect.t fails
perl 5.14.2 RHEL5 3471.6: chdir to <BUILD>/DBIx-Class-0.08198 3471.6: <DISTRO-PERL> Makefile.PL && make && make test && make install *** Module::AutoInstall version 1.06 *** Checking for Perl dependencies... [Core Features] - DBD::SQLite ...loaded. (1.37 >= 1.29) - File::Temp ...loaded. (0.22 >= 0.22) - Package::Stash ...loaded. (0.33 >= 0.28) - Test::Builder ...loaded. (0.98 >= 0.94) - Test::Exception ...loaded. (0.31 >= 0.31) - Test::More ...loaded. (0.98 >= 0.94) - Test::Warn ...loaded. (0.24 >= 0.21) - Class::Accessor::Grouped ...loaded. (0.10006 >= 0.10002) - Class::C3::Componentised ...loaded. (1.001000 >= 1.0009) - Class::Inspector ...loaded. (1.27 >= 1.24) - Class::Method::Modifiers ...loaded. (1.09 >= 1.06) - Config::Any ...loaded. (0.23 >= 0.20) - Context::Preserve ...loaded. (0.01 >= 0.01) - DBI ...loaded. (1.622 >= 1.57) - Data::Compare ...loaded. (1.22 >= 1.22) - Data::Dumper::Concise ...loaded. (2.020 >= 2.020) - Data::Page ...loaded. (2.02 >= 2.00) - Devel::GlobalDestruction ...loaded. (0.06) - File::Path ...loaded. (2.08_01 >= 2.07) - Hash::Merge ...loaded. (0.12 >= 0.12) - MRO::Compat ...loaded. (0.11 >= 0.09) - Module::Find ...loaded. (0.11 >= 0.06) - Moo ...loaded. (0.091014 >= 0.009100) - Path::Class ...loaded. (0.26 >= 0.18) - SQL::Abstract ...loaded. (1.73 >= 1.73) - Scope::Guard ...loaded. (0.20 >= 0.03) - Sub::Name ...loaded. (0.05 >= 0.04) - Try::Tiny ...loaded. (0.11 >= 0.04) - namespace::clean ...loaded. (0.23 >= 0.20) - strictures ...loaded. (1.004001 >= 1.003001) *** Module::AutoInstall configuration finished. t/storage/reconnect.t ............................ 4/? # Failed test 'The operation succeeded' # at t/storage/reconnect.t line 69. # died: DBIx::Class::Exception (DBIx::Class::ResultSet::search(): DBI Exception: DBD::SQLite::db prepare_cached failed: disk I/O error [for Statement "SELECT me.artistid, me.name, me.rank, me.charfield FROM artist me ORDER BY name DESC"] at t/storage/reconnect.t line 68 # ) # Failed test 'Three artists returned' # at t/storage/reconnect.t line 70. # got: 0 # expected: 3 # Looks like you failed 2 tests of 36. t/storage/reconnect.t ............................ Dubious, test returned 2 (wstat 512, 0x200) Failed 2/36 subtests FYI t/100populate.t .................................. 1/? datatype mismatch: bind param (0) foo as integer at /opt/perl/uq.cis.perl-dmt-toys.rhel5-5.14.2-20120716/lib/site_perl/5.14.2/x86_64- linux/DBI.pm line 1985, <> line 1. my build system builds dependency graph based on META.* files so added some manual dependencies 'DBIx::Class' => [ 'unlisted', # actually from DBIx::Class::Optional::Dependencies, so depend on Moose rather than falling back to Moo 'JSON::Any', 'Moose', 'MooseX::Types', 'MooseX::Types::JSON', 'MooseX::Types::Path::Class', 'namespace::autoclean', 'Getopt::Long::Descriptive', 'Text::CSV', # DateTime for some tests, e.g. t/96_is_deteministic_value.t 'DateTime', 'DateTime::Format::Strptime', 'DateTime::Format::SQLite' ],
From: obrien.jk [...] gmail.com
I also see these failed tests. I noticed another warning, more than likely unrelated, but pasted here for what it's worth... t/51threadtxn.t .................................. skipped: Set $ENV{DBICTEST_PG_DSN}, _USER and _PASS to run this test (note: creates and drops a table named artist!) Unhandled type: REGEXP at /usr/local/share/perl/5.14.2/Devel/Cycle.pm line 107, <> line 1.
From: d.thomas [...] its.uq.edu.au
On Wed Jul 18 10:46:10 2012, jkobrien wrote: Show quoted text
> I noticed another warning, more than likely unrelated, but pasted here > for what it's worth... > > Unhandled type: REGEXP at /usr/local/share/perl/5.14.2/Devel/Cycle.pm > line 107, <> line 1.
I didn't see this because the perl I build includes patch from https://rt.cpan.org/Public/Bug/Display.html?id=56681 also forgot to mention 0.08196 built in same perl did not fail. 0.08198 still failed after I'd rolled back some modules, e.g. DBD::SQlite. I forgot to try an older version on Moo. However t/storage/reconnect.h has changed quite a bit so maybe the test is now reporting an issue that's been around for a while, or the problem is in new test ?
Far as I can see, the failure is due to a chmod 000 expecting the file to be unreadable, which isn't going to be the case if running as root. Attached patch to demonstrate the test passing using an alternative approach (dangling symlink), doubt it's the right approach due to win32 etc. but maybe it'll help point someone in the right direction.
Subject: dbic-reconnect.patch
diff -uNPr DBIx-Class-0.08198-original/t/storage/reconnect.t DBIx-Class-0.08198-ING4dz/t/storage/reconnect.t --- DBIx-Class-0.08198-original/t/storage/reconnect.t 2012-07-10 21:43:26.000000000 +0100 +++ DBIx-Class-0.08198-ING4dz/t/storage/reconnect.t 2012-07-27 19:06:53.663385365 +0100 @@ -40,10 +40,17 @@ $schema->storage->_dbh->disconnect; move( $db_orig, $db_tmp ) or die "failed to move $db_orig to $db_tmp: $!"; -open DBFILE, '>', $db_orig; +# first clear out everything +open DBFILE, '>', "$db_orig-xxx" or die $!; print DBFILE 'THIS IS NOT A REAL DATABASE'; close DBFILE; -chmod 0000, $db_orig; +# we want an unreadable file, try a dangling symlink first +if(symlink "$db_orig-xxx", $db_orig) { + unlink "$db_orig-xxx" or die "failed to unlink - $!"; +} else { + # and if we can't do that, fall back to chmod 000 + chmod 0000, $db_orig; +} ### Try the operation again... it should fail, since there's no db {
had a request for a test which demonstrates the issue outside DBIC, not sure if it's much help since it's just a repetition of the below comment but see attached. Fails as root, passes as user. On Fri Jul 27 14:13:48 2012, TEAM wrote: Show quoted text
> Far as I can see, the failure is due to a chmod 000 expecting the file > to be unreadable, which isn't going to be the case if running as root. > > Attached patch to demonstrate the test passing using an alternative > approach (dangling symlink), doubt it's the right approach due to win32 > etc. but maybe it'll help point someone in the right direction. > >
Subject: sqlite-unreadable-file.t
#!/usr/bin/perl use strict; use warnings; use Test::More tests => 1; use Test::Fatal; use DBI; # DBD::SQLite; my $file = 'test.db'; my $dbh = DBI->connect('dbi:SQLite:dbname=test.db', '', '', { RaiseError => 1 }); $dbh->do(q{create table test (id integer primary key)}); chmod 000, $file; like(exception { $dbh = DBI->connect('dbi:SQLite:dbname=test.db', '', '', { RaiseError => 1 }); $dbh->do(q{select * from test}) }, qr/unable to open database file/, 'cannot read with chmod 000'); unlink $file;
FYI I sent this to one of our SQLite contacts with a more complete test that passes for user and fails for root: #!/usr/bin/env perl use strict; use warnings; use Test::More; use Test::Fatal; use File::Copy 'move'; use DBI; my $file = 'test.db'; my $db_tmp = 'test.db.tmp'; my $dbh = DBI->connect('dbi:SQLite:dbname=test.db', '', '', {RaiseError => 1}); $dbh->do(q{create table test (id integer primary key, name varchar(30))}); $dbh->do(q{insert into test(name) VALUES(?)}, {}, $_) for qw(frew bar baz); my $sth = $dbh->prepare('SELECT COUNT(*) as foo FROM test'); $sth->execute; is ($sth->fetchrow_hashref->{foo}, 3, 'actually connected'); move $file, "$file.tmp" or die "could not move file: $!"; { open my $tmp, '>', $file; print $tmp 'THIS IS NOT A REAL DATABASE'; close $tmp; chmod 0000, $file; } { my $w; local $SIG{__WARN__} = sub { $w = shift }; $dbh->disconnect; ok ($w !~ /active statement handles/, 'SQLite can disconnect properly'); } like( exception { $dbh = DBI->connect('dbi:SQLite:dbname=test.db', '', '', {RaiseError => 1}); $dbh->do(q{select * from test}); }, qr/unable to open database file/, 'cannot read db' ); unlink($file) or die "could not delete $file: $!"; move( $db_tmp, $file ) or die "could not move $db_tmp to $file: $!"; $dbh = DBI->connect('dbi:SQLite:dbname=test.db', '', '', {RaiseError => 1}); ### Try the operation again... this time, it should succeed ok( !exception { $dbh->do(q{select * from test}), }, 'The operation succeeded'); done_testing; END { unlink 'test.db'; unlink 'test.db.tmp'; } __END__ tungsten [27637] ~/tmp $ /usr/bin/perl foo.pl ok 1 - actually connected ok 2 - SQLite can disconnect properly ok 3 - cannot read db ok 4 - The operation succeeded 1..4 tungsten [27638] ~/tmp $ sudo /usr/bin/perl foo.pl ok 1 - actually connected ok 2 - SQLite can disconnect properly DBD::SQLite::db do failed: file is encrypted or is not a database at foo.pl line 39. not ok 3 - cannot read db # Failed test 'cannot read db' # at foo.pl line 41. # 'DBD::SQLite::db do failed: file is encrypted or is not a database at foo.pl line 39. # ' # doesn't match '(?^:unable to open database file)' ok 4 - The operation succeeded 1..4 # Looks like you failed 1 test of 4.
DBIC fix (explanation in commit) pushed as for_current/riba/fix_sqlite_ping_RT78420
Just to note that this bug is still present in 0.08200
This was finally (properly) fixed in 0.08203. Cheers.