Skip Menu |

This queue is for tickets about the DBD-Pg CPAN distribution.

Report information
The Basics
Id: 83638
Status: resolved
Priority: 0/
Queue: DBD-Pg

People
Owner: greg [...] turnstep.com
Requestors: ribasushi [...] leporine.io
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: (no value)
Fixed in: 3.0.0



Subject: Multiple redefinition warnings on thread spawn under 5.17.x
These are new for the 5.17 series, and appear only under prove -w / make test. Examples of smoking the same code under 5.16.2 and blead (5.17.10). Look towards the end - the noisy tests are t/51threads.t and t/51threadtxn.t 5.16.2 https://api.travis-ci.org/jobs/5002549/log.txt?deansi=true 5.17.10-to-be https://api.travis-ci.org/jobs/5002551/log.txt?deansi=true
Actually the report is incorrect - these warnings happen on *any perl*. I did not see them under 5.16 because the perl in question was not built with ithreads <headdesk />. I am also not entirely sure whether this is a DBD::Pg or a DBI issue.
This is caused by DBD::Pg->CLONE() and DBD::Pg->driver() conspiring to re-register all the driver methods in the child thread. $ perl -MDBI -MDBD::Pg -Mthreads -wE 'DBI->setup_driver("DBD::Pg"); DBD::Pg->driver; my $t = threads->create(sub { say "in thread"; DBD::Pg->driver }); $t->join' in thread Subroutine DBI::db::pg_cancel redefined at /home/ilmari/.perlbrew/libs/18.1t@std/lib/perl5/x86_64-linux-thread-multi/DBI.pm line 1393. Subroutine DBI::db::pg_endcopy redefined at /home/ilmari/.perlbrew/libs/18.1t@std/lib/perl5/x86_64-linux-thread-multi/DBI.pm line 1393. Subroutine DBI::db::pg_getline redefined at /home/ilmari/.perlbrew/libs/18.1t@std/lib/perl5/x86_64-linux-thread-multi/DBI.pm line 1393. Subroutine DBI::db::pg_getcopydata redefined at /home/ilmari/.perlbrew/libs/18.1t@std/lib/perl5/x86_64-linux-thread-multi/DBI.pm line 1393. Subroutine DBI::db::pg_getcopydata_async redefined at /home/ilmari/.perlbrew/libs/18.1t@std/lib/perl5/x86_64-linux-thread-multi/DBI.pm line 1393. Subroutine DBI::db::pg_notifies redefined at /home/ilmari/.perlbrew/libs/18.1t@std/lib/perl5/x86_64-linux-thread-multi/DBI.pm line 1393. Subroutine DBI::db::pg_putcopydata redefined at /home/ilmari/.perlbrew/libs/18.1t@std/lib/perl5/x86_64-linux-thread-multi/DBI.pm line 1393. Subroutine DBI::db::pg_putcopyend redefined at /home/ilmari/.perlbrew/libs/18.1t@std/lib/perl5/x86_64-linux-thread-multi/DBI.pm line 1393. Subroutine DBI::db::pg_ping redefined at /home/ilmari/.perlbrew/libs/18.1t@std/lib/perl5/x86_64-linux-thread-multi/DBI.pm line 1393. Subroutine DBI::db::pg_putline redefined at /home/ilmari/.perlbrew/libs/18.1t@std/lib/perl5/x86_64-linux-thread-multi/DBI.pm line 1393. Subroutine DBI::db::pg_ready redefined at /home/ilmari/.perlbrew/libs/18.1t@std/lib/perl5/x86_64-linux-thread-multi/DBI.pm line 1393. Subroutine DBI::db::pg_release redefined at /home/ilmari/.perlbrew/libs/18.1t@std/lib/perl5/x86_64-linux-thread-multi/DBI.pm line 1393. Subroutine DBI::db::pg_result redefined at /home/ilmari/.perlbrew/libs/18.1t@std/lib/perl5/x86_64-linux-thread-multi/DBI.pm line 1393. Subroutine DBI::db::pg_rollback_to redefined at /home/ilmari/.perlbrew/libs/18.1t@std/lib/perl5/x86_64-linux-thread-multi/DBI.pm line 1393. Subroutine DBI::db::pg_savepoint redefined at /home/ilmari/.perlbrew/libs/18.1t@std/lib/perl5/x86_64-linux-thread-multi/DBI.pm line 1393. Subroutine DBI::db::pg_server_trace redefined at /home/ilmari/.perlbrew/libs/18.1t@std/lib/perl5/x86_64-linux-thread-multi/DBI.pm line 1393. Subroutine DBI::db::pg_server_untrace redefined at /home/ilmari/.perlbrew/libs/18.1t@std/lib/perl5/x86_64-linux-thread-multi/DBI.pm line 1393. Subroutine DBI::db::pg_type_info redefined at /home/ilmari/.perlbrew/libs/18.1t@std/lib/perl5/x86_64-linux-thread-multi/DBI.pm line 1393. Subroutine DBI::st::pg_cancel redefined at /home/ilmari/.perlbrew/libs/18.1t@std/lib/perl5/x86_64-linux-thread-multi/DBI.pm line 1393. Subroutine DBI::st::pg_result redefined at /home/ilmari/.perlbrew/libs/18.1t@std/lib/perl5/x86_64-linux-thread-multi/DBI.pm line 1393. Subroutine DBI::st::pg_ready redefined at /home/ilmari/.perlbrew/libs/18.1t@std/lib/perl5/x86_64-linux-thread-multi/DBI.pm line 1393. Subroutine DBI::db::pg_lo_creat redefined at /home/ilmari/.perlbrew/libs/18.1t@std/lib/perl5/x86_64-linux-thread-multi/DBI.pm line 1393. Subroutine DBI::db::pg_lo_open redefined at /home/ilmari/.perlbrew/libs/18.1t@std/lib/perl5/x86_64-linux-thread-multi/DBI.pm line 1393. Subroutine DBI::db::pg_lo_write redefined at /home/ilmari/.perlbrew/libs/18.1t@std/lib/perl5/x86_64-linux-thread-multi/DBI.pm line 1393. Subroutine DBI::db::pg_lo_read redefined at /home/ilmari/.perlbrew/libs/18.1t@std/lib/perl5/x86_64-linux-thread-multi/DBI.pm line 1393. Subroutine DBI::db::pg_lo_lseek redefined at /home/ilmari/.perlbrew/libs/18.1t@std/lib/perl5/x86_64-linux-thread-multi/DBI.pm line 1393. Subroutine DBI::db::pg_lo_tell redefined at /home/ilmari/.perlbrew/libs/18.1t@std/lib/perl5/x86_64-linux-thread-multi/DBI.pm line 1393. Subroutine DBI::db::pg_lo_close redefined at /home/ilmari/.perlbrew/libs/18.1t@std/lib/perl5/x86_64-linux-thread-multi/DBI.pm line 1393. Subroutine DBI::db::pg_lo_unlink redefined at /home/ilmari/.perlbrew/libs/18.1t@std/lib/perl5/x86_64-linux-thread-multi/DBI.pm line 1393. Subroutine DBI::db::pg_lo_import redefined at /home/ilmari/.perlbrew/libs/18.1t@std/lib/perl5/x86_64-linux-thread-multi/DBI.pm line 1393. Subroutine DBI::db::pg_lo_import_with_oid redefined at /home/ilmari/.perlbrew/libs/18.1t@std/lib/perl5/x86_64-linux-thread-multi/DBI.pm line 1393. Subroutine DBI::db::pg_lo_export redefined at /home/ilmari/.perlbrew/libs/18.1t@std/lib/perl5/x86_64-linux-thread-multi/DBI.pm line 1393.
Subject: [rt.cpan.org #83638] [PATCH] Avoid reinstalling driver methods in threads (CPAN bug #83638)
Date: Tue, 15 Oct 2013 12:19:01 +0100
To: bug-DBD-Pg [...] rt.cpan.org
From: Dagfinn Ilmari Mannsåker <ilmari [...] ilmari.org>
--- Changes | 3 +++ Pg.pm | 74 ++++++++++++++++++++++++++++++++++------------------------------- 2 files changed, 42 insertions(+), 35 deletions(-) diff --git a/Changes b/Changes index c2d484f..c16483b 100644 --- a/Changes +++ b/Changes @@ -51,6 +51,9 @@ Version 3.0.0? - Adjust test to use 3 digit exponential values (CPAN bug #59449) + - Avoid reinstalling driver methods in threads (CPAN bug #83638) + [Dagfinn Ilmari Mannsåker] + Version 2.19.3 Released August 21, 2012 (git commit be018f10fdaf4163f98affcb7244046e8f47420d) - Fix bug in pg_st_split_statement causing segfaults diff --git a/Pg.pm b/Pg.pm index 7f73e06..7ddffda 100644 --- a/Pg.pm +++ b/Pg.pm @@ -107,6 +107,7 @@ use 5.008004; return 'pg_catalog.'; } + my $methods_are_installed = 0; sub driver { return $drh if defined $drh; my($class, $attr) = @_; @@ -122,41 +123,44 @@ use 5.008004; 'Attribution' => "DBD::Pg $VERSION by Greg Sabino Mullane and others", }); - - DBD::Pg::db->install_method('pg_cancel'); - DBD::Pg::db->install_method('pg_endcopy'); - DBD::Pg::db->install_method('pg_getline'); - DBD::Pg::db->install_method('pg_getcopydata'); - DBD::Pg::db->install_method('pg_getcopydata_async'); - DBD::Pg::db->install_method('pg_notifies'); - DBD::Pg::db->install_method('pg_putcopydata'); - DBD::Pg::db->install_method('pg_putcopyend'); - DBD::Pg::db->install_method('pg_ping'); - DBD::Pg::db->install_method('pg_putline'); - DBD::Pg::db->install_method('pg_ready'); - DBD::Pg::db->install_method('pg_release'); - DBD::Pg::db->install_method('pg_result'); ## NOT duplicated below! - DBD::Pg::db->install_method('pg_rollback_to'); - DBD::Pg::db->install_method('pg_savepoint'); - DBD::Pg::db->install_method('pg_server_trace'); - DBD::Pg::db->install_method('pg_server_untrace'); - DBD::Pg::db->install_method('pg_type_info'); - - DBD::Pg::st->install_method('pg_cancel'); - DBD::Pg::st->install_method('pg_result'); - DBD::Pg::st->install_method('pg_ready'); - - DBD::Pg::db->install_method('pg_lo_creat'); - DBD::Pg::db->install_method('pg_lo_open'); - DBD::Pg::db->install_method('pg_lo_write'); - DBD::Pg::db->install_method('pg_lo_read'); - DBD::Pg::db->install_method('pg_lo_lseek'); - DBD::Pg::db->install_method('pg_lo_tell'); - DBD::Pg::db->install_method('pg_lo_close'); - DBD::Pg::db->install_method('pg_lo_unlink'); - DBD::Pg::db->install_method('pg_lo_import'); - DBD::Pg::db->install_method('pg_lo_import_with_oid'); - DBD::Pg::db->install_method('pg_lo_export'); + if (!$methods_are_installed) { + DBD::Pg::db->install_method('pg_cancel'); + DBD::Pg::db->install_method('pg_endcopy'); + DBD::Pg::db->install_method('pg_getline'); + DBD::Pg::db->install_method('pg_getcopydata'); + DBD::Pg::db->install_method('pg_getcopydata_async'); + DBD::Pg::db->install_method('pg_notifies'); + DBD::Pg::db->install_method('pg_putcopydata'); + DBD::Pg::db->install_method('pg_putcopyend'); + DBD::Pg::db->install_method('pg_ping'); + DBD::Pg::db->install_method('pg_putline'); + DBD::Pg::db->install_method('pg_ready'); + DBD::Pg::db->install_method('pg_release'); + DBD::Pg::db->install_method('pg_result'); ## NOT duplicated below! + DBD::Pg::db->install_method('pg_rollback_to'); + DBD::Pg::db->install_method('pg_savepoint'); + DBD::Pg::db->install_method('pg_server_trace'); + DBD::Pg::db->install_method('pg_server_untrace'); + DBD::Pg::db->install_method('pg_type_info'); + + DBD::Pg::st->install_method('pg_cancel'); + DBD::Pg::st->install_method('pg_result'); + DBD::Pg::st->install_method('pg_ready'); + + DBD::Pg::db->install_method('pg_lo_creat'); + DBD::Pg::db->install_method('pg_lo_open'); + DBD::Pg::db->install_method('pg_lo_write'); + DBD::Pg::db->install_method('pg_lo_read'); + DBD::Pg::db->install_method('pg_lo_lseek'); + DBD::Pg::db->install_method('pg_lo_tell'); + DBD::Pg::db->install_method('pg_lo_close'); + DBD::Pg::db->install_method('pg_lo_unlink'); + DBD::Pg::db->install_method('pg_lo_import'); + DBD::Pg::db->install_method('pg_lo_import_with_oid'); + DBD::Pg::db->install_method('pg_lo_export'); + + $methods_are_installed++; + } return $drh; -- 1.8.1.2
Thank you both for the report and the patch. Applied in 252b346beb0db4d19dc440cc6bc49fe50c350b47